Skip to content

Commit

Permalink
Initial commit of Conditional Locations Sample App
Browse files Browse the repository at this point in the history
  • Loading branch information
adammw committed May 27, 2014
1 parent ddc5934 commit ce2e0aa
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 0 deletions.
48 changes: 48 additions & 0 deletions conditional_locations_sample_app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Copyright 2014 Zendesk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

ADDITIONAL TERMS AND CONDITIONS

Capitalized terms used herein have the meaning set forth in the
Zendesk, Inc. (“Zendesk”) Terms of Service (available at www.zendesk.com/company/terms)
(the “Terms”). The software made available herein constitutes the source code for a
Zendesk Application (“Application Software”) which may be implemented to
enable features or functionality to be utilized in connection with a subscription
to the Service. Notwithstanding anything to the contrary set forth in the Terms
or any other agreement by and between you and Zendesk, Application Software is
provided “AS IS” and on an “AS AVAILABLE” basis, and that Zendesk makes no warranty
as to the Application Software. ZENDESK DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND THOSE ARISING FROM A COURSE
OF DEALING OR USAGE OF TRADE RELATED TO THE APPLICATION SOFTWARE, ITS USE OR ANY INABILITY
TO USE IT OR THE RESULTS OF ITS USE.

Zendesk makes Zendesk Applications available for use through the user interface of
the Service in the manner described (for each Zendesk Application) at www.zendesk.com/apps
(“Service Implementation”). Use of Application Software, other than in connection with a
Service Implementation is subject to the following risks and conditions: (i) the Application
Software may contain errors, design flaws or other problems; and (ii) use of the Application
Software may result in unexpected results, loss of data, project delays or other unpredictable
damage or loss. Zendesk only supports the Application Software currently available and installed
through the Service Implementation. By utilizing Application Software other than in connection
with the Service Implementation, you are agreeing that Zendesk shall have no obligation to
correct any bugs, defects or errors in the Application Software you have utilized or
otherwise to support or maintain the Application Software you have utilized.

If you elect to utilize any Application Software other than through a Service Implementation,
you are agreeing to release Zendesk from any claim with regard to the Application Software,
its operation, availability or its failure to operate or be available.
Without limiting the generality of the foregoing, You acknowledge and agree that neither the use,
availability nor operation of any Application Software shall be subject to any service level
commitment applicable to the Service.
9 changes: 9 additions & 0 deletions conditional_locations_sample_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:warning: *Use of this software is subject to important terms and conditions as set forth in the License file* :warning:

# Conditional Locations Sample App

This App is designed to teach App developers about Conditonal Locations.

Conditional Locations allow your app to dynamically hide and show itself on Zendesk.

Please submit bug reports to [Zendesk Support]([email protected]). Pull requests are welcome.
3 changes: 3 additions & 0 deletions conditional_locations_sample_app/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.current-location {
margin-bottom: 12px;
}
89 changes: 89 additions & 0 deletions conditional_locations_sample_app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
(function() {

return {
events: {
'app.created': 'onAppCreated',
'click .hide-btn': 'onHideBtnClick',
'click .show-btn': 'onShowBtnClick',
'message.hide': 'onHideMessageRecieved',
'message.show': 'onShowMessageRecieved'
},

locations: {
top_bar: {
name: 'Top Bar',
visible: true
},
nav_bar: {
name: 'Nav Bar',
visible: true
},
ticket_sidebar: {
name: 'Ticket Sidebar',
visible: false // specified as noTemplate in the manfiest, therefore will be hidden by default
}
},

// Event Handlers

onAppCreated: function() {
this.renderControls();
},

onHideBtnClick: function(e) {
var location = this.$(e.target).parents('[data-location]').data('location');
this.hideLocation(location);
this.renderControls();
},

onShowBtnClick: function(e) {
var location = this.$(e.target).parents('[data-location]').data('location');
this.showLocation(location);
this.renderControls();
},

onHideMessageRecieved: function(data) {
this.locations[data.location].visible = false;
if (data.location == this.currentLocation()) {
this.hide();
}
this.renderControls();
},

onShowMessageRecieved: function(data) {
this.locations[data.location].visible = true;
if (data.location == this.currentLocation()) {
this.show();
}
this.renderControls();
},

// Actions

renderControls: function() {
this.switchTo('controls', {
currentLocation: this.locations[this.currentLocation()],
locations: this.locations
});
},

hideLocation: function(location) {
this.locations[location].visible = false;
if (location == this.currentLocation()) {
this.hide();
} else {
this.message('hide', {location: location});
}
},

showLocation: function(location) {
this.locations[location].visible = true;
if (location == this.currentLocation()) {
this.show();
} else {
this.message('show', {location: location});
}
}
};

}());
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added conditional_locations_sample_app/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions conditional_locations_sample_app/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Conditional Locations Sample App",
"author": {
"name": "Zendesk",
"email": "[email protected]"
},
"defaultLocale": "en",
"private": true,
"location": ["ticket_sidebar", "top_bar", "nav_bar"],
"noTemplate": ["ticket_sidebar"],
"version": "1.0",
"frameworkVersion": "1.0"
}
17 changes: 17 additions & 0 deletions conditional_locations_sample_app/templates/controls.hdbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<p class="current-location">This is the <strong>{{currentLocation.name}}</strong>.</p>

<table class="table">
<tbody>
{{#each locations}}
<tr data-location="{{@key}}">
<th>{{name}}</th>
<td>
<div class="btn-group" data-toggle="buttons-radio">
<button class="btn show-btn {{#if visible}}active{{/if}}">Show</button>
<button class="btn hide-btn {{#unless visible}}active{{/unless}}">Hide</button>
</div>
</td>
</tr>
{{/each}}
</tbody>
</table>
10 changes: 10 additions & 0 deletions conditional_locations_sample_app/templates/layout.hdbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<header>
<span class="logo"/>
<h3>{{setting "name"}}</h3>
</header>
<section data-main/>
<footer>
<a href="mailto:{{author.email}}">
{{author.name}}
</a>
</footer>
13 changes: 13 additions & 0 deletions conditional_locations_sample_app/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"app": {
"package": "conditonal_locations_sample_app",
"description": {
"value": "This app demonstrates how to use conditonal locations APIs",
"title": "app description"
},
"name": {
"value": "Conditonal Locations Sample App",
"title": "app name"
}
}
}

0 comments on commit ce2e0aa

Please sign in to comment.