Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'tirejs'

  • Loading branch information...
commit 7626ce34aea7a449a59f2083bdceda14a9e26f1b 2 parents d9aa8a9 + bd4d247
Massimiliano Marcon authored
3  .jshintrc
View
@@ -3,7 +3,8 @@
"globals": {
"jQuery": true,
"nokia": true,
- "Zepto": true
+ "Zepto": true,
+ "tire": true
},
"browser": true,
7 Makefile
View
@@ -8,7 +8,7 @@ RUNNER = test/SpecRunner.html
deps:
@npm install
-dist: hint plugin zepto extensions summary
+dist: hint plugin zepto tire extensions summary
plugin:
@./node_modules/.bin/uglifyjs -nc -o dist/$(PLUGIN).min.js src/$(PLUGIN).js
@@ -16,6 +16,9 @@ plugin:
zepto:
@./node_modules/.bin/uglifyjs -nc -o dist/zepto.adapter.min.js src/zepto.adapter.js
+tire:
+ @./node_modules/.bin/uglifyjs -nc -o dist/tire.adapter.min.js src/tire.adapter.js
+
extensions:
@./build-scripts/build-extensions.sh
@@ -35,4 +38,4 @@ website: doc
test: deps
@sed 's/\/\*\*\*_\*\*\*\//$(INJECTORS)/g' src/$(PLUGIN).js > $(TESTED_CODE); \
command -v phantomjs >/dev/null 2>&1 || { echo >&2 "PhantomJS not installed. Run the tests from the browser."; exit 0; }; \
- ./node_modules/.bin/phantom-jasmine $(RUNNER)
+ ./node_modules/.bin/phantom-jasmine $(RUNNER)
1  dist/tire.adapter.min.js
View
@@ -0,0 +1 @@
+(function(e){function t(){e.each(this.queue,function(e,t){typeof t=="function"&&t.call(null)})}function u(e){return e._zid||(e._zid=o++)}e.error=function(e){throw new Error(e)},e.Deferred=function(){if(!(this instanceof e.Deferred))return new e.Deferred;this.queue=[],this._state="pending"};var n=e.Deferred.prototype,r,i,s;n.resolve=function(){this._state="resolved",t.call(this)},n.state=function(){return this._state},n.done=function(e){if(this._state==="pending"){this.queue.push(e);return}e.call(null)},r=function(){this.store={},this.counter=0},i=r.prototype,i.data=function(e,t,n){if(!n)return this.store[e.__data]&&this.store[e.__data][t];e.__data||(e.__data="cache"+this.counter++),this.store[e.__data]=this.store[e.__data]||{},this.store[e.__data][t]=n},i.removeData=function(e,t){if(t){this.store[e.__data][t]=null;return}this.store[e.__data]=null},s=new r,e.data=function(){return s.data.apply(s,arguments)},e.removeData=function(){return s.removeData.apply(s,arguments)};var o=1;e.proxy=function(t,n){if(e.isFunction(t)){var r=function(){return t.apply(n,arguments)};return r._zid=u(t),r}if(typeof n=="string")return e.proxy(t[n],t);throw new TypeError("expected function")},e.inArray=function(e,t,n){return[].indexOf.call(t,e,n)},e.Event=function(t,n){typeof t!="string"&&(n=t,t=n.type);var r=document.createEvent((t.match(/click|mouse/)?"Mouse":"")+"Events"),i=!0;return n&&(e.each(n,function(e,t,n,s){s=e==="bubbles"?i=!!t:r[e]=t}),r.initEvent(t,i,!0,null,null,null,null,null,null,null,null,null,null,null,null),r.isDefaultPrevented=function(){return this.defaultPrevented}),r},window.jQuery=e})(tire);
295 src/examples/example.tire.html
View
@@ -0,0 +1,295 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <title>HTML5 boilerplate—all you really need…</title>
+ <style>
+ #map {
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ background: white;
+ }
+ </style>
+</head>
+
+<body>
+<div id="map"></div>
+<script type="text/javascript" src="http://lab.marcon.me/jhere/tire.js"></script>
+<script type="text/javascript" src="../tire.adapter.js"></script>
+<!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> -->
+<script type="text/javascript" src="../jhere.js"></script>
+<script type="text/javascript">
+var heatMapData = [
+ {
+ "value": 4899,
+ "latitude": 52.53026126658807,
+ "longitude": 13.385298362512387
+ },
+ {
+ "value": 3299,
+ "latitude": 52.530712612721196,
+ "longitude": 13.385059833526611
+ },
+ {
+ "value": 36,
+ "latitude": 52.530215905734003,
+ "longitude": 13.38543057664563
+ },
+ {
+ "value": 680,
+ "latitude": 52.530870437622099,
+ "longitude": 13.3849096298218
+ },
+ {
+ "value": 289,
+ "latitude": 52.530234520737004,
+ "longitude": 13.385648693847036
+ },
+ {
+ "value": 27,
+ "latitude": 52.530488537560281,
+ "longitude": 13.385252371995787
+ },
+ {
+ "value": 38,
+ "latitude": 52.530063626141377,
+ "longitude": 13.385473500409793
+ },
+ {
+ "value": 89,
+ "latitude": 52.530244890211264,
+ "longitude": 13.385788119172863
+ },
+ {
+ "value": 6,
+ "latitude": 52.530253983437007,
+ "longitude": 13.385760004534591
+ },
+ {
+ "value": 164,
+ "latitude": 52.529855659002003,
+ "longitude": 13.384268417202721
+ },
+ {
+ "value": 687,
+ "latitude": 52.529975,
+ "longitude": 13.383993
+ },
+ {
+ "value": 1347,
+ "latitude": 52.529565942430487,
+ "longitude": 13.384504666194712
+ },
+ {
+ "value": 34,
+ "latitude": 52.530347321620944,
+ "longitude": 13.385677040788089
+ },
+ {
+ "value": 184,
+ "latitude": 52.530878000000001,
+ "longitude": 13.384904000000001
+ },
+ {
+ "value": 172,
+ "latitude": 52.529768647948352,
+ "longitude": 13.384791244138654
+ },
+ {
+ "value": 479,
+ "latitude": 52.530803986958468,
+ "longitude": 13.387076854705811
+ },
+ {
+ "value": 128,
+ "latitude": 52.530900000000003,
+ "longitude": 13.3847
+ },
+ {
+ "value": 17,
+ "latitude": 52.529969969813301,
+ "longitude": 13.385131331173101
+ },
+ {
+ "value": 18,
+ "latitude": 52.530900000000003,
+ "longitude": 13.3849
+ },
+ {
+ "value": 3,
+ "latitude": 52.530006959735175,
+ "longitude": 13.385183469129728
+ },
+ {
+ "value": 169,
+ "latitude": 52.529605748442059,
+ "longitude": 13.384814799655908
+ },
+ {
+ "value": 308,
+ "latitude": 52.530434197093939,
+ "longitude": 13.385883058015915
+ },
+ {
+ "value": 71,
+ "latitude": 52.530757000000001,
+ "longitude": 13.384383
+ },
+ {
+ "value": 716,
+ "latitude": 52.530304999999998,
+ "longitude": 13.383474319999999
+ },
+ {
+ "value": 7,
+ "latitude": 52.530581520484056,
+ "longitude": 13.386184774537549
+ },
+ {
+ "value": 3,
+ "latitude": 52.530765175608799,
+ "longitude": 13.384771001626588
+ },
+ {
+ "value": 297,
+ "latitude": 52.530719317584662,
+ "longitude": 13.383554065723375
+ },
+ {
+ "value": 687,
+ "latitude": 52.530542917204741,
+ "longitude": 13.383557796478271
+ },
+ {
+ "value": 13,
+ "latitude": 52.530131948860614,
+ "longitude": 13.386342364840072
+ },
+ {
+ "value": 5,
+ "latitude": 52.530000000000001,
+ "longitude": 13.3851
+ },
+ {
+ "value": 68,
+ "latitude": 52.530712612721196,
+ "longitude": 13.384780883789062
+ },
+ {
+ "value": 21,
+ "latitude": 52.530496999999997,
+ "longitude": 13.385122349999998
+ },
+ {
+ "value": 210,
+ "latitude": 52.529994665670216,
+ "longitude": 13.38409423828125
+ },
+ {
+ "value": 5,
+ "latitude": 52.530973479671822,
+ "longitude": 13.3848509841156
+ },
+ {
+ "value": 220,
+ "latitude": 52.529781999999997,
+ "longitude": 13.38395
+ },
+ {
+ "value": 212,
+ "latitude": 52.530653999999998,
+ "longitude": 13.383659
+ },
+ {
+ "value": 56,
+ "latitude": 52.530817064808303,
+ "longitude": 13.383900201050393
+ },
+ {
+ "value": 88,
+ "latitude": 52.530654962765965,
+ "longitude": 13.383485390706522
+ },
+ {
+ "value": 19,
+ "latitude": 52.530841000000002,
+ "longitude": 13.384907999999999
+ },
+ {
+ "value": 7,
+ "latitude": 52.530961968053603,
+ "longitude": 13.384805275139801
+ },
+ {
+ "value": 376,
+ "latitude": 52.529297467355825,
+ "longitude": 13.384428562870935
+ },
+ {
+ "value": 824,
+ "latitude": 52.529055867792856,
+ "longitude": 13.385228922324478
+ },
+ {
+ "value": 25,
+ "latitude": 52.530738935100189,
+ "longitude": 13.38375270869002
+ },
+ {
+ "value": 157,
+ "latitude": 52.530112148718082,
+ "longitude": 13.383579254150391
+ },
+ {
+ "value": 44,
+ "latitude": 52.530441122208984,
+ "longitude": 13.386257713051902
+ },
+ {
+ "value": 32,
+ "latitude": 52.529431550962173,
+ "longitude": 13.384827986540591
+ },
+ {
+ "value": 235,
+ "latitude": 52.530798030550265,
+ "longitude": 13.383918592731648
+ },
+ {
+ "value": 211,
+ "latitude": 52.529138000000003,
+ "longitude": 13.384971
+ },
+ {
+ "value": 41,
+ "latitude": 52.531100735356837,
+ "longitude": 13.386037485323744
+ },
+ {
+ "value": 28,
+ "latitude": 52.529808973752715,
+ "longitude": 13.383999001205726
+ }
+];
+</script>
+<script type="text/javascript">
+$(window).on('load', function(){
+ //Set default credentials
+ $.jHERE.defaultCredentials('_peU-uCkp-j8ovkzFGNU', 'gBoUkAMoxoqIWfxWA5DuMQ');
+
+ $('#map').jHERE({enable: ['behavior', 'zoombar', 'typeselector', 'positioning', 'contextmenu']});
+ $('#map').jHERE('type', 'smart').jHERE('marker', [52.49, 13.37], {text: '', textColor: '#fff', fill: '#004C9A',
+ click: function(e){
+ alert(JSON.stringify(e.geo));
+ }}).jHERE('marker', [52.49, 13.39], {text: '', textColor: '#fff', fill: '#004C9A',
+ click: function(e){
+ $(this).jHERE('bubble', [52.49, 13.39], {content: JSON.stringify(e.geo), closable: false});
+ }}).jHERE('heatmap', heatMapData, 'value');
+ $('#map').jHERE('kml', 'resources/berlin.kml', true);
+ });
+</script>
+</body>
+</html>
133 src/tire.adapter.js
View
@@ -0,0 +1,133 @@
+/*
+Copyright (c) 2013 Massimiliano Marcon, http://marcon.me
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+;(function($){
+ $.error = function(msg){
+ throw new Error(msg);
+ };
+ /*MINIMAL implementation of $.Deferred*/
+ /*This only implements the method required by jHERE*/
+ /*So do not use it for real "promises" purpose*/
+ $.Deferred = function(){
+ if(!(this instanceof $.Deferred)) {
+ return new $.Deferred();
+ }
+ this.queue = [];
+ this._state = 'pending';
+ };
+
+ function callCallbacks(){
+ $.each(this.queue, function(i, fn){
+ if(typeof fn === 'function') {
+ fn.call(null);
+ }
+ });
+ }
+
+ var D = $.Deferred.prototype, Data, P, d;
+ D.resolve = function(){
+ this._state = 'resolved';
+ callCallbacks.call(this);
+ };
+ D.state = function(){
+ return this._state;
+ };
+ D.done = function(callback){
+ if(this._state === 'pending') {
+ this.queue.push(callback);
+ return;
+ }
+ callback.call(null);
+ };
+
+ Data = function(){
+ this.store = {};
+ this.counter = 0;
+ };
+ P = Data.prototype;
+ P.data = function(element, key, object){
+ if(!object) {
+ //getter
+ return this.store[element.__data] && this.store[element.__data][key];
+ }
+ if(!element.__data) {
+ element.__data = 'cache' + this.counter++;
+ }
+ this.store[element.__data] = this.store[element.__data] || {};
+ this.store[element.__data][key] = object;
+ };
+ P.removeData = function(element, key){
+ if(key) {
+ this.store[element.__data][key] = null;
+ return;
+ }
+ this.store[element.__data] = null;
+ };
+
+ d = new Data();
+ $.data = function(){
+ return d.data.apply(d, arguments);
+ };
+ $.removeData = function(){
+ return d.removeData.apply(d, arguments);
+ };
+
+ //Export Zepto as jQuery so there is no need
+ //to check for it in the plugin.
+
+ //$.proxy implementation from Zepto source code
+ var _zid = 1;
+ function zid(element) {
+ return element._zid || (element._zid = _zid++);
+ }
+ $.proxy = function(fn, context) {
+ if ($.isFunction(fn)) {
+ var proxyFn = function(){ return fn.apply(context, arguments); };
+ proxyFn._zid = zid(fn);
+ return proxyFn;
+ } else if (typeof context === 'string') {
+ return $.proxy(fn[context], fn);
+ } else {
+ throw new TypeError("expected function");
+ }
+ };
+ //$.inArray implementation from Zepto source code
+ $.inArray = function(elem, array, i){
+ return [].indexOf.call(array, elem, i);
+ };
+ $.Event = function(type, props) {
+ if (typeof type !== 'string') {
+ props = type;
+ type = props.type;
+ }
+ var event = document.createEvent((type.match(/click|mouse/) ? 'Mouse' : '') + 'Events'), bubbles = true;
+ if (props) {
+ $.each(props, function(name, value, a, x){
+ x = (name === 'bubbles') ? (bubbles = !!value) : (event[name] = value);
+ });
+ event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null);
+ event.isDefaultPrevented = function(){ return this.defaultPrevented; };
+ }
+ return event;
+ };
+ window.jQuery = $;
+}(tire));
Please sign in to comment.
Something went wrong with that request. Please try again.