diff --git a/Gruntfile.js b/Gruntfile.js index cfcf3e9..396fc05 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,6 +24,8 @@ 'libs/jquery.ui.touch-punch.js', 'libs/jquery.ui.touch-punch.js', 'libs/js-expression-eval/parser.js', + // Before + 'src/plugins/github-api.js', // Iframework 'src/iframework.js', 'src/iframework-utils.js', @@ -56,7 +58,6 @@ 'src/plugins/source.js', 'src/plugins/library.js', 'src/plugins/images.js', - 'src/plugins/github-api.js', // 'src/plugins/towtruck.js', // All Iframework loaded 'src/iframework-last.js', diff --git a/build/meemoo-iframework.js b/build/meemoo-iframework.js index 074cead..60f3d50 100644 --- a/build/meemoo-iframework.js +++ b/build/meemoo-iframework.js @@ -1,4 +1,4 @@ -/*! Meemoo Iframework http://meemoo.org/ - v0.3.5 - 2024-12-23 (8:49:13 PM GMT+0200) +/*! Meemoo Iframework http://meemoo.org/ - v0.3.5 - 2024-12-26 (5:34:19 PM GMT+0200) * Copyright (c) 2024 Forrest Oliphant; Licensed MIT, AGPL. */ (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); (function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.0.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=k[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var S=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var T=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(S.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace($,"(?:$1)?").replace(T,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var O=/msie [\w.]+/;var C=/\/$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.substr(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({},{root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=O.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(P,"/");if(r&&this._wantsHashChange){this.iframe=a.$(''; Iframework.NodeBoxIframeView = Iframework.NodeBoxView.extend({ @@ -6377,15 +6579,16 @@ $(function(){ Iframework.NodeBoxView.prototype.initialize.call(this); // Add refresh button - this.$("button.remove") - .after( - $('') - ); + this.$('button.remove').after( + $( + '' + ) + ); // Add refresh event - this.events["click .refresh"] = "refresh"; + this.events['click .refresh'] = 'refresh'; // .inner style for css - this.$(".inner").addClass("iframe-type"); + this.$('.inner').addClass('iframe-type'); var self = this; this.iframe.onload = function () { @@ -6395,45 +6598,41 @@ $(function(){ render: function () { this.$el.html(this.template(this.model)); - this.iframe = document.createElement("iframe"); + this.iframe = document.createElement('iframe'); $(this.iframe).attr({ - "class": "iframe", - "name": this.model.frameIndex, - "src": this.model.get("src") + class: 'iframe', + name: this.model.frameIndex, + src: this.model.get('src'), }); - this.$(".inner").html( this.iframe ); + this.$('.inner').html(this.iframe); return this; }, refresh: function () { - this.$("iframe")[0].src = this.model.get("src"); - } - + this.$('iframe')[0].src = this.model.get('src'); + }, }); - }); -$(function(){ - +$(function () { Iframework.Port = Backbone.Model.extend({ defaults: { - name: "", - type: "", - description: "", - "default": null + name: '', + type: '', + description: '', + default: null, }, initialize: function () { - if (this.get("type")==="") { + if (this.get('type') === '') { // No type set, connect to anything - this.set("type", "all"); + this.set('type', 'all'); } - this.parentNode = this.get("parentNode"); + this.parentNode = this.get('parentNode'); // To sanitize data:image/gif types for css class // this.set( "type_class", this.get("type").split("/")[0].replace(":", "_") ); - this.set( "type_class", this.get("type").split(":")[0] ); + this.set('type_class', this.get('type').split(':')[0]); this.Edges = new Iframework.Edges(); - }, // Ports keep track of connected edges connect: function (edge) { @@ -6444,7 +6643,7 @@ $(function(){ }, remove: function () { // Disconnect edges - while(this.Edges.length > 0) { + while (this.Edges.length > 0) { var edge = this.Edges.at(0); this.parentNode.parentGraph.removeEdge(edge); } @@ -6452,17 +6651,16 @@ $(function(){ if (this.view) { this.view.remove(); } - } + }, }); - + Iframework.Ports = Backbone.Collection.extend({ - model: Iframework.Port + model: Iframework.Port, }); - }); -$(function(){ - +$(function () { + // prettier-ignore var popupTemplate = '
'+ ''+ @@ -6471,6 +6669,7 @@ $(function(){ // '

'+ '
'; + // prettier-ignore var edgeEditTemplate = '
'+ '<%= label() %>'+ @@ -6480,22 +6679,22 @@ $(function(){ var accepts = {}; Iframework.PortView = Backbone.View.extend({ - tagName: "div", - className: "port", + tagName: 'div', + className: 'port', popupTemplate: _.template(popupTemplate), edgeEditTemplate: _.template(edgeEditTemplate), events: { - "mousedown": "highlightEdge", - "click .hole": "clickhole", - "dragstart .hole": "dragstart", - "drag .hole, .holehelper": "drag", - "dragstop .hole, .holehelper": "dragstop", - "dragstart .plugend": "unplugstart", - "drag .plugend": "unplugdrag", - "dragstop .plugend": "unplugstop", - "drop": "drop", - "click .disconnect": "disconnect", - "submit .manualinput": "manualinput" + mousedown: 'highlightEdge', + 'click .hole': 'clickhole', + 'dragstart .hole': 'dragstart', + 'drag .hole, .holehelper': 'drag', + 'dragstop .hole, .holehelper': 'dragstop', + 'dragstart .plugend': 'unplugstart', + 'drag .plugend': 'unplugdrag', + 'dragstop .plugend': 'unplugstop', + drop: 'drop', + 'click .disconnect': 'disconnect', + 'submit .manualinput': 'manualinput', // "click .publish-port": "publishPort" }, initialize: function () { @@ -6505,13 +6704,18 @@ $(function(){ dragstart: function (event, ui) { // Add a mask so that iframes don't steal mouse this.model.node.parentGraph.view.maskFrames(); - + // Highlight matching ins or outs - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole") - .addClass('fade'); - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + (this.model.isIn ? 'out' : 'in') + ' span.hole' + ).addClass('fade'); + $( + 'div.ports-' + + (this.model.isIn ? 'out' : 'in') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); Iframework.edgePreview = edgePreview; @@ -6527,13 +6731,13 @@ $(function(){ var dragY = ui.offset.top + 8 + Iframework.shownGraph.view.el.scrollTop; var thisX = this.portOffsetLeft(); var thisY = this.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? dragX-2 : thisX), - fromY: (this.model.isIn ? dragY : thisY), - toX: (this.model.isIn ? thisX : dragX+20), - toY: (this.model.isIn ? thisY : dragY) + fromX: this.model.isIn ? dragX - 2 : thisX, + fromY: this.model.isIn ? dragY : thisY, + toX: this.model.isIn ? thisX : dragX + 20, + toY: this.model.isIn ? thisY : dragY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -6545,12 +6749,12 @@ $(function(){ // Remove iframe masks this.model.node.parentGraph.view.unmaskFrames(); - $(".hole").removeClass("fade highlight"); - + $('.hole').removeClass('fade highlight'); + // Edge preview Iframework.edgePreview.remove(); Iframework.edgePreview = undefined; - if (this.relatedEdges().length < 1){ + if (this.relatedEdges().length < 1) { this.$('.plugend').hide(); } @@ -6564,19 +6768,19 @@ $(function(){ this.armDelete = false; } else { // Connect wire - var from = $(ui.draggable).data("model"); + var from = $(ui.draggable).data('model'); var to = this.model; - var source = (this.model.isIn ? from : to); - var target = (this.model.isIn ? to : from); + var source = this.model.isIn ? from : to; + var target = this.model.isIn ? to : from; var edge = new Iframework.Edge({ - source: [source.node.get("id"), source.get("name")], - target: [target.node.get("id"), target.get("name")], - parentGraph: this.model.parentGraph + source: [source.node.get('id'), source.get('name')], + target: [target.node.get('id'), target.get('name')], + parentGraph: this.model.parentGraph, }); if (Iframework.edgePreview) { edge._color = Iframework.edgePreview._color; } - if (edge.parentGraph.addEdge(edge)){ + if (edge.parentGraph.addEdge(edge)) { edge.connect(); } } @@ -6589,12 +6793,16 @@ $(function(){ topConnectedEdge: function () { var topConnected; var topZ = 0; - _.each(this.relatedEdges(), function(edge){ - if (edge.view._z >= topZ) { - topZ = edge.view._z; - topConnected = edge; - } - }, this); + _.each( + this.relatedEdges(), + function (edge) { + if (edge.view._z >= topZ) { + topZ = edge.view._z; + topConnected = edge; + } + }, + this + ); return topConnected; }, unplugstart: function (event, ui) { @@ -6603,21 +6811,29 @@ $(function(){ // Find top connected wire var lastConnected = this.topConnectedEdge(); - if (!lastConnected) { return false; } + if (!lastConnected) { + return false; + } this.unpluggingEdge = lastConnected; this.unpluggingEdge.view.dim(); - if (this.relatedEdges().length===1) { - this.$(".plugend").hide(); + if (this.relatedEdges().length === 1) { + this.$('.plugend').hide(); } - var thatPort = this.model.isIn ? this.unpluggingEdge.Source : this.unpluggingEdge.Target; - this.$(".plugend").data("model", thatPort); - + var thatPort = this.model.isIn + ? this.unpluggingEdge.Source + : this.unpluggingEdge.Target; + this.$('.plugend').data('model', thatPort); + // Highlight related ins or outs - $("div.ports-"+(this.model.isIn ? "in" : "out")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + + (this.model.isIn ? 'in' : 'out') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); edgePreview.setColor(this.unpluggingEdge.view._color); @@ -6632,16 +6848,18 @@ $(function(){ if (Iframework.edgePreview && this.unpluggingEdge) { var dragX = ui.offset.left + Iframework.shownGraph.view.el.scrollLeft; var dragY = ui.offset.top + 6 + Iframework.shownGraph.view.el.scrollTop; - var thatPortView = this.model.isIn ? this.unpluggingEdge.Source.view : this.unpluggingEdge.Target.view; + var thatPortView = this.model.isIn + ? this.unpluggingEdge.Source.view + : this.unpluggingEdge.Target.view; var thatX = thatPortView.portOffsetLeft(); var thatY = thatPortView.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? thatX : dragX-2), - fromY: (this.model.isIn ? thatY : dragY), - toX: (this.model.isIn ? dragX+20 : thatX), - toY: (this.model.isIn ? dragY : thatY) + fromX: this.model.isIn ? thatX : dragX - 2, + fromY: this.model.isIn ? thatY : dragY, + toX: this.model.isIn ? dragX + 20 : thatX, + toY: this.model.isIn ? dragY : thatY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -6653,7 +6871,7 @@ $(function(){ if (this.armDelete && this.unpluggingEdge) { this.model.parentGraph.removeEdge(this.unpluggingEdge); } else { - this.$(".plugend").show(); + this.$('.plugend').show(); this.unpluggingEdge.view.undim(); } this.armDelete = false; @@ -6664,111 +6882,113 @@ $(function(){ clickhole: function (event) { // Hide previous connected edges editor $('div.edge-edit').remove(); - - var hole = this.$(".hole"); - + + var hole = this.$('.hole'); + // Show connected edges editor var isIn = this.model.isIn; - var portName = this.model.get("name"); - + var portName = this.model.get('name'); + var popupEl = this.popupTemplate(this.model.toJSON()); popupEl = $(popupEl); this.$el.append(popupEl); // Close button - popupEl.children("button.close") + popupEl + .children('button.close') .button({ icons: { - primary: "icon-cancel" + primary: 'icon-cancel', }, - text: false + text: false, }) - .click(function(){ + .click(function () { $('div.edge-edit').remove(); Iframework.selectedPort = null; }); - var typeabbr = this.model.get("type").substring(0,3); + var typeabbr = this.model.get('type').substring(0, 3); if (isIn) { var showForm = false; - var inputForm = $('
') - .attr({ - "id": this.model.node.id + "_" + this.model.get("name"), - "class": "manualinput" - }); - if (typeabbr === "int" || typeabbr === "num" || typeabbr === "flo" ) { + var inputForm = $('').attr({ + id: this.model.node.id + '_' + this.model.get('name'), + class: 'manualinput', + }); + if (typeabbr === 'int' || typeabbr === 'num' || typeabbr === 'flo') { showForm = true; inputForm.append( - $("").attr({ - "type": "number", - "min": hole.data("min"), - "max": hole.data("max"), - "step": "any", - "value": this.model.node.get("state")[this.model.get("name")] + $('').attr({ + type: 'number', + min: hole.data('min'), + max: hole.data('max'), + step: 'any', + value: this.model.node.get('state')[this.model.get('name')], }) ); - } else if (typeabbr === "col" || typeabbr === "str") { + } else if (typeabbr === 'col' || typeabbr === 'str') { showForm = true; inputForm.append( - $("").attr({ - "type": "text", - "maxlength": hole.data("max"), - "value": this.model.node.get("state")[this.model.get("name")] + $('').attr({ + type: 'text', + maxlength: hole.data('max'), + value: this.model.node.get('state')[this.model.get('name')], }) ); - } else if (typeabbr === "boo") { + } else if (typeabbr === 'boo') { showForm = true; - var val = this.model.node.get("state")[this.model.get("name")]; - val = (Boolean(val) && val !== "false"); + var val = this.model.node.get('state')[this.model.get('name')]; + val = Boolean(val) && val !== 'false'; inputForm.append( - $("") - .attr({ - "type": "checkbox", - "checked": val - }) + $('').attr({ + type: 'checkbox', + checked: val, + }) ); - } else if (typeabbr === "ban") { - inputForm.append(" "); + } else if (typeabbr === 'ban') { + inputForm.append(' '); showForm = true; } if (showForm) { inputForm.append( - $("") - .html("send") + $('') + .html('send') .attr({ - "type": "submit", - "class": "send", - "title": "send value to module" + type: 'submit', + class: 'send', + title: 'send value to module', }) .button({ icons: { - primary: "icon-ok" + primary: 'icon-ok', }, - text: false + text: false, }) ); popupEl.append(inputForm); } } - $("#select_"+this.model.id) - .button({ - icons: { - primary: "ui-icon-power" - } - }); + $('#select_' + this.model.id).button({ + icons: { + primary: 'ui-icon-power', + }, + }); if (this.relatedEdges().length > 0) { popupEl.append('

disconnect

'); - _.each(this.relatedEdges(), function (edge) { - var edgeEditEl = this.edgeEditTemplate(edge.view); - popupEl.append(edgeEditEl); - }, this); + _.each( + this.relatedEdges(), + function (edge) { + var edgeEditEl = this.edgeEditTemplate(edge.view); + popupEl.append(edgeEditEl); + }, + this + ); } // This input's options - if (this.model.get("options") && this.model.get("options").length > 0) { + if (this.model.get('options') && this.model.get('options').length > 0) { this.$('input').autocomplete({ minLength: 0, - source: this.model.get("options") + source: this.model.get('options'), }); } @@ -6776,38 +6996,43 @@ $(function(){ event.stopPropagation(); }, manualinput: function (event) { - var inputname = this.model.get("name"); + var inputname = this.model.get('name'); var val; - if (this.$(".manualinput").children("input")){ - val = this.$(".manualinput").children("input").val(); + if (this.$('.manualinput').children('input')) { + val = this.$('.manualinput').children('input').val(); } - if (this.$(".manualinput").children("input:checkbox").length > 0) { - if (this.$(".manualinput").children("input:checkbox").is(':checked')) { + if (this.$('.manualinput').children('input:checkbox').length > 0) { + if (this.$('.manualinput').children('input:checkbox').is(':checked')) { val = true; } else { val = false; } } - if (this.model.get("type") === "int") { + if (this.model.get('type') === 'int') { val = parseInt(val, 10); } - if (this.model.get("type") === "number" || this.model.get("type") === "float") { + if ( + this.model.get('type') === 'number' || + this.model.get('type') === 'float' + ) { val = parseFloat(val); } if (val === undefined) { - val = "!"; + val = '!'; } var message = {}; message[inputname] = val; this.model.node.receive(message); - this.model.node.get("state")[inputname] = val; - this.model.node.trigger("change"); + this.model.node.get('state')[inputname] = val; + this.model.node.trigger('change'); // $('div.edge-edit').remove(); return false; }, disconnect: function (event) { //HACK - var edge = this.model.parentGraph.get("edges").getByCid( $(event.target).parents(".edge-edit-item").attr("id") ); + var edge = this.model.parentGraph + .get('edges') + .getByCid($(event.target).parents('.edge-edit-item').attr('id')); if (edge) { this.model.parentGraph.removeEdge(edge); } @@ -6821,7 +7046,11 @@ $(function(){ var holeoffset = this.$('.hole').offset(); if (holeoffset) { // HACK - return holeoffset.left + 7 + this.model.parentNode.parentGraph.view.el.scrollLeft; + return ( + holeoffset.left + + 7 + + this.model.parentNode.parentGraph.view.el.scrollLeft + ); } else { return 0; } @@ -6830,7 +7059,11 @@ $(function(){ var holeoffset = this.$('.hole').offset(); if (holeoffset) { // HACK - return holeoffset.top + 10 + this.model.parentNode.parentGraph.view.el.scrollTop; + return ( + holeoffset.top + + 10 + + this.model.parentNode.parentGraph.view.el.scrollTop + ); } else { return 0; } @@ -6838,15 +7071,17 @@ $(function(){ _relatedEdges: null, relatedEdges: function () { // Resets to null on dis/connect - if ( this._relatedEdges === null ) { - this._relatedEdges = this.model.parentGraph.get("edges").filter( function (edge) { - return ( edge.Source === this.model || edge.Target === this.model ); - }, this); + if (this._relatedEdges === null) { + this._relatedEdges = this.model.parentGraph + .get('edges') + .filter(function (edge) { + return edge.Source === this.model || edge.Target === this.model; + }, this); // Toggle plugends if (this._relatedEdges.length >= 1) { - this.$(".plugend").show(); + this.$('.plugend').show(); } else { - this.$(".plugend").hide(); + this.$('.plugend').hide(); } this.model.node.view.resetRelatedEdges(); } @@ -6867,46 +7102,42 @@ $(function(){ }, highlight: function () { // Called by edge view - var plugend = this.$(".plugend"); - plugend.addClass("highlight"); - setTimeout(function(){ - plugend.removeClass("highlight"); + var plugend = this.$('.plugend'); + plugend.addClass('highlight'); + setTimeout(function () { + plugend.removeClass('highlight'); }, 1000); }, publishPort: function () { // i/o - }//, + }, //, // remove: function () { // } - }); - }); -$(function(){ - +$(function () { Iframework.PortIn = Iframework.Port.extend({ defaults: { - name: "", - type: "", - description: "", - "default": null + name: '', + type: '', + description: '', + default: null, }, initializeView: function () { - this.view = new Iframework.PortInView({model:this}); + this.view = new Iframework.PortInView({model: this}); return this.view; - } + }, }); - + Iframework.PortsIn = Backbone.Collection.extend({ - model: Iframework.PortIn + model: Iframework.PortIn, }); - }); -$(function(){ - - var portInTemplate = +$(function () { + // prettier-ignore + var portInTemplate = '
'+ ''+ '<%= name %>'+ @@ -6914,83 +7145,90 @@ $(function(){ ''; Iframework.PortInView = Iframework.PortView.extend({ - tagName: "div", - className: "port", + tagName: 'div', + className: 'port', portInTemplate: _.template(portInTemplate), events: { - "mousedown": "highlightEdge", - "click .hole": "clickhole", - "dragstart .hole": "dragstart", - "drag .hole, .holehelper": "drag", - "dragstop .hole, .holehelper": "dragstop", - "dragstart .plugend": "unplugstart", - "drag .plugend": "unplugdrag", - "dragstop .plugend": "unplugstop", - "drop": "drop", - "click .disconnect": "disconnect", - "submit .manualinput": "manualinput" - // "click .publish-port": "publishPort" - }, - render: function () { - this.$el.html( this.portInTemplate(this.model.toJSON()) ); - this.$el.addClass("port-in"); - this.$(".hole") - .draggable({ - helper: function (e) { - return $(''); - } - }); - this.$(".plugend") - .draggable({ - helper: function (e) { - return $(''); - } - }); + mousedown: 'highlightEdge', + 'click .hole': 'clickhole', + 'dragstart .hole': 'dragstart', + 'drag .hole, .holehelper': 'drag', + 'dragstop .hole, .holehelper': 'dragstop', + 'dragstart .plugend': 'unplugstart', + 'drag .plugend': 'unplugdrag', + 'dragstop .plugend': 'unplugstop', + drop: 'drop', + 'click .disconnect': 'disconnect', + 'submit .manualinput': 'manualinput', + // "click .publish-port": "publishPort" + }, + render: function () { + this.$el.html(this.portInTemplate(this.model.toJSON())); + this.$el.addClass('port-in'); + this.$('.hole').draggable({ + helper: function (e) { + return $(''); + }, + }); + this.$('.plugend').draggable({ + helper: function (e) { + return $(''); + }, + }); // Drag from hole - this.$(".hole") - .data({ - model: this.model - }); - + this.$('.hole').data({ + model: this.model, + }); + // The whole port is droppable - var accept = ""; - var type = this.model.get("type_class"); - if (type === "all" || type === "bang"){ + var accept = ''; + var type = this.model.get('type_class'); + if (type === 'all' || type === 'bang') { // Anything can hit an in bang - accept = ".hole-out, .plugend-in"; + accept = '.hole-out, .plugend-in'; } else { - accept = ".hole-out.hole-all, .hole-out.hole-"+type+", .plugend-in.plugend-all, .plugend-in.plugend-"+type; + accept = + '.hole-out.hole-all, .hole-out.hole-' + + type + + ', .plugend-in.plugend-all, .plugend-in.plugend-' + + type; } - if (type === "string"){ + if (type === 'string') { // HACK to allow int and float -> string - accept += ", .hole-out.hole-int, .hole-out.hole-float, .plugend-in.plugend-int, .plugend-in.plugend-float"; + accept += + ', .hole-out.hole-int, .hole-out.hole-float, .plugend-in.plugend-int, .plugend-in.plugend-float'; } - if (type === "int" || type === "float" || type === "number") { + if (type === 'int' || type === 'float' || type === 'number') { // HACK to allow all int float number to connect - accept += ", .hole-out.hole-int, .hole-out.hole-float, .hole-out.hole-number, .plugend-in.plugend-int, .plugend-in.plugend-float, .plugend-in.plugend-number"; + accept += + ', .hole-out.hole-int, .hole-out.hole-float, .hole-out.hole-number, .plugend-in.plugend-int, .plugend-in.plugend-float, .plugend-in.plugend-number'; } this.$el.droppable({ - "hoverClass": "drophover", - "accept": accept + hoverClass: 'drophover', + accept: accept, }); - this.$(".plugend").hide(); + this.$('.plugend').hide(); // Disable selection for better drag+drop - this.$(".portshown").disableSelection(); - + this.$('.portshown').disableSelection(); }, dragstart: function (event, ui) { // Add a mask so that iframes don't steal mouse this.model.node.parentGraph.view.maskFrames(); - + // Highlight matching ins or outs - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole") - .addClass('fade'); - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + (this.model.isIn ? 'out' : 'in') + ' span.hole' + ).addClass('fade'); + $( + 'div.ports-' + + (this.model.isIn ? 'out' : 'in') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); Iframework.edgePreview = edgePreview; @@ -7006,13 +7244,13 @@ $(function(){ var dragY = ui.offset.top + 8 + Iframework.shownGraph.view.el.scrollTop; var thisX = this.portOffsetLeft(); var thisY = this.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? dragX-2 : thisX), - fromY: (this.model.isIn ? dragY : thisY), - toX: (this.model.isIn ? thisX : dragX+20), - toY: (this.model.isIn ? thisY : dragY) + fromX: this.model.isIn ? dragX - 2 : thisX, + fromY: this.model.isIn ? dragY : thisY, + toX: this.model.isIn ? thisX : dragX + 20, + toY: this.model.isIn ? thisY : dragY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -7024,12 +7262,12 @@ $(function(){ // Remove iframe masks this.model.node.parentGraph.view.unmaskFrames(); - $(".hole").removeClass("fade highlight"); - + $('.hole').removeClass('fade highlight'); + // Edge preview Iframework.edgePreview.remove(); Iframework.edgePreview = undefined; - if (this.relatedEdges().length < 1){ + if (this.relatedEdges().length < 1) { this.$('.plugend').hide(); } @@ -7043,19 +7281,19 @@ $(function(){ this.armDelete = false; } else { // Connect wire - var from = $(ui.draggable).data("model"); + var from = $(ui.draggable).data('model'); var to = this.model; - var source = (this.model.isIn ? from : to); - var target = (this.model.isIn ? to : from); + var source = this.model.isIn ? from : to; + var target = this.model.isIn ? to : from; var edge = new Iframework.Edge({ source: [source.node.id, source.id], target: [target.node.id, target.id], - parentGraph: this.model.parentNode.parentGraph + parentGraph: this.model.parentNode.parentGraph, }); if (Iframework.edgePreview) { edge._color = Iframework.edgePreview._color; } - if (edge.parentGraph.addEdge(edge)){ + if (edge.parentGraph.addEdge(edge)) { edge.connect(); } } @@ -7068,12 +7306,16 @@ $(function(){ topConnectedEdge: function () { var topConnected; var topZ = 0; - _.each(this.relatedEdges(), function(edge){ - if (edge.view._z >= topZ) { - topZ = edge.view._z; - topConnected = edge; - } - }, this); + _.each( + this.relatedEdges(), + function (edge) { + if (edge.view._z >= topZ) { + topZ = edge.view._z; + topConnected = edge; + } + }, + this + ); return topConnected; }, unplugstart: function (event, ui) { @@ -7082,21 +7324,29 @@ $(function(){ // Find top connected wire var lastConnected = this.topConnectedEdge(); - if (!lastConnected) { return false; } + if (!lastConnected) { + return false; + } this.unpluggingEdge = lastConnected; this.unpluggingEdge.view.dim(); - if (this.relatedEdges().length===1) { - this.$(".plugend").hide(); + if (this.relatedEdges().length === 1) { + this.$('.plugend').hide(); } - var thatPort = this.model.isIn ? this.unpluggingEdge.Source : this.unpluggingEdge.Target; - this.$(".plugend").data("model", thatPort); - + var thatPort = this.model.isIn + ? this.unpluggingEdge.Source + : this.unpluggingEdge.Target; + this.$('.plugend').data('model', thatPort); + // Highlight related ins or outs - $("div.ports-"+(this.model.isIn ? "in" : "out")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + + (this.model.isIn ? 'in' : 'out') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); edgePreview.setColor(this.unpluggingEdge.view._color); @@ -7111,16 +7361,18 @@ $(function(){ if (Iframework.edgePreview && this.unpluggingEdge) { var dragX = ui.offset.left + Iframework.shownGraph.view.el.scrollLeft; var dragY = ui.offset.top + 6 + Iframework.shownGraph.view.el.scrollTop; - var thatPortView = this.model.isIn ? this.unpluggingEdge.Source.view : this.unpluggingEdge.Target.view; + var thatPortView = this.model.isIn + ? this.unpluggingEdge.Source.view + : this.unpluggingEdge.Target.view; var thatX = thatPortView.portOffsetLeft(); var thatY = thatPortView.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? thatX : dragX-2), - fromY: (this.model.isIn ? thatY : dragY), - toX: (this.model.isIn ? dragX+20 : thatX), - toY: (this.model.isIn ? dragY : thatY) + fromX: this.model.isIn ? thatX : dragX - 2, + fromY: this.model.isIn ? thatY : dragY, + toX: this.model.isIn ? dragX + 20 : thatX, + toY: this.model.isIn ? dragY : thatY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -7132,7 +7384,7 @@ $(function(){ if (this.armDelete && this.unpluggingEdge) { this.model.parentGraph.removeEdge(this.unpluggingEdge); } else { - this.$(".plugend").show(); + this.$('.plugend').show(); this.unpluggingEdge.view.undim(); } this.armDelete = false; @@ -7143,57 +7395,54 @@ $(function(){ clickhole: function (event) { // Hide previous connected edges editor $('div.edge-edit').remove(); - - var hole = this.$(".hole"); - + + var hole = this.$('.hole'); + // Show connected edges editor var isIn = this.model.isIn; - var portName = this.model.get("name"); - + var portName = this.model.get('name'); + var popupEl = this.popupTemplate(this.model.toJSON()); popupEl = $(popupEl); this.$el.append(popupEl); // Close button - popupEl.children("button.close") - .click(function(){ - $('div.edge-edit').remove(); - Iframework.selectedPort = null; - }); + popupEl.children('button.close').click(function () { + $('div.edge-edit').remove(); + Iframework.selectedPort = null; + }); - var typeabbr = this.model.get("type").substring(0,3); + var typeabbr = this.model.get('type').substring(0, 3); var showForm = false; - var inputForm = $('') - .attr({ - "id": this.model.node.id + "_" + this.model.get("name"), - "class": "manualinput", - "novalidate": "" - }); - if (typeabbr === "int" || typeabbr === "num" || typeabbr === "flo" ) { + var inputForm = $('').attr({ + id: this.model.node.id + '_' + this.model.get('name'), + class: 'manualinput', + novalidate: '', + }); + if (typeabbr === 'int' || typeabbr === 'num' || typeabbr === 'flo') { showForm = true; inputForm.append( - $("").attr({ + $('').attr({ // "type": "number", // "min": hole.data("min"), // "max": hole.data("max"), // "step": "any", - "value": this.model.node.get("state")[this.model.get("name")], - "title": 'use equations like "=x*100" to change all incoming values' + value: this.model.node.get('state')[this.model.get('name')], + title: 'use equations like "=x*100" to change all incoming values', }) ); - } else if (typeabbr === "col") { + } else if (typeabbr === 'col') { // Use the spectrum event instead of standard form submit showForm = true; - var color = this.model.node.get("state")[this.model.get("name")]; - var input = $("") - .attr({ - "type": "text", - "maxlength": 140, - "value": color, - "style": "width: 90%" - }); - inputForm.append( input ); + var color = this.model.node.get('state')[this.model.get('name')]; + var input = $('').attr({ + type: 'text', + maxlength: 140, + value: color, + style: 'width: 90%', + }); + inputForm.append(input); // Has to be after added to page var self = this; input @@ -7205,96 +7454,99 @@ $(function(){ showPalette: true, palette: [ Iframework.wireColors, - ["red", "green", "blue", "purple", "cyan", "magenta", "yellow"], - ["black", "#333", "#666", "#999", "#AAA", "#CCC", "white"] + ['red', 'green', 'blue', 'purple', 'cyan', 'magenta', 'yellow'], + ['black', '#333', '#666', '#999', '#AAA', '#CCC', 'white'], ], showSelectionPalette: true, - localStorageKey: "iframework.settings.colorPalette", - change: function(color) { + localStorageKey: 'iframework.settings.colorPalette', + change: function (color) { // TODO change to toString when https://github.com/bgrins/spectrum/issues/92 fixed - var str = color.toRgbString(); - input.val( str ); + var str = color.toRgbString(); + input.val(str); self.model.node.receive(portName, str); self.model.node.setValue(portName, str); }, - hide: function(color) { + hide: function (color) { input.show(); }, beforeShow: function () { - input.spectrum("set", input.val()); + input.spectrum('set', input.val()); input.hide(); - } + }, }) .show(); // Unhide - } else if (typeabbr === "str") { + } else if (typeabbr === 'str') { showForm = true; inputForm.append( - $("").attr({ - "type": "text", - "maxlength": hole.data("max"), - "value": this.model.node.get("state")[this.model.get("name")] + $('').attr({ + type: 'text', + maxlength: hole.data('max'), + value: this.model.node.get('state')[this.model.get('name')], }) ); - } else if (typeabbr === "arr") { + } else if (typeabbr === 'arr') { showForm = true; - var a = this.model.node.get("state")[this.model.get("name")]; - if (Iframework.util.type(a) !== "array") { a = []; } - var s = ""; - for (var i=0; i0 ? ", " : "") + a[i]; + var a = this.model.node.get('state')[this.model.get('name')]; + if (Iframework.util.type(a) !== 'array') { + a = []; + } + var s = ''; + for (var i = 0; i < a.length; i++) { + s += (i > 0 ? ', ' : '') + a[i]; } inputForm.append( - $("").attr({ - "type": "text", - "value": s + $('').attr({ + type: 'text', + value: s, }) ); - } else if (typeabbr === "boo") { + } else if (typeabbr === 'boo') { showForm = true; - var val = this.model.node.get("state")[this.model.get("name")]; - val = (Boolean(val) && val !== "false"); + var val = this.model.node.get('state')[this.model.get('name')]; + val = Boolean(val) && val !== 'false'; inputForm.append( - $("") - .attr({ - "type": "checkbox", - "checked": val - }) + $('').attr({ + type: 'checkbox', + checked: val, + }) ); - } else if (typeabbr === "ban") { - inputForm.append(" "); + } else if (typeabbr === 'ban') { + inputForm.append(' '); showForm = true; } if (showForm) { inputForm.append( - $("") - .attr({ - "type": "submit", - "class": "send icon-ok", - "title": "send value to module" - }) + $('').attr({ + type: 'submit', + class: 'send icon-ok', + title: 'send value to module', + }) ); popupEl.append(inputForm); } - - $("#select_"+this.model.id) - .button({ - icons: { - primary: "ui-icon-power" - } - }); + + $('#select_' + this.model.id).button({ + icons: { + primary: 'ui-icon-power', + }, + }); if (this.relatedEdges().length > 0) { popupEl.append('

disconnect

'); - _.each(this.relatedEdges(), function (edge) { - var edgeEditEl = this.edgeEditTemplate(edge.view); - popupEl.append(edgeEditEl); - }, this); + _.each( + this.relatedEdges(), + function (edge) { + var edgeEditEl = this.edgeEditTemplate(edge.view); + popupEl.append(edgeEditEl); + }, + this + ); } // This input's options - if (this.model.get("options") && this.model.get("options").length > 0) { + if (this.model.get('options') && this.model.get('options').length > 0) { this.$('input').autocomplete({ minLength: 0, - source: this.model.get("options") + source: this.model.get('options'), }); } @@ -7302,34 +7554,34 @@ $(function(){ event.stopPropagation(); }, manualinput: function (event) { - var inputname = this.model.get("name"); - var type = this.model.get("type"); - var typeabbr = type.substring(0,3); + var inputname = this.model.get('name'); + var type = this.model.get('type'); + var typeabbr = type.substring(0, 3); var val; var saveToState = true; - if (this.$(".manualinput").children("input")){ - val = this.$(".manualinput").children("input").val(); + if (this.$('.manualinput').children('input')) { + val = this.$('.manualinput').children('input').val(); } - if (this.$(".manualinput").children("input:checkbox").length > 0) { - if (this.$(".manualinput").children("input:checkbox").is(':checked')) { + if (this.$('.manualinput').children('input:checkbox').length > 0) { + if (this.$('.manualinput').children('input:checkbox').is(':checked')) { val = true; } else { val = false; } } - if (type === "int" || type === "number" || type === "float") { - if (typeof val === "string" && val.toString().substr(0,1)==="=") { + if (type === 'int' || type === 'number' || type === 'float') { + if (typeof val === 'string' && val.toString().substr(0, 1) === '=') { // Try to parse equation - } else if (type === "int") { + } else if (type === 'int') { val = parseInt(val, 10); - } else if (type === "number" || type === "float") { + } else if (type === 'number' || type === 'float') { val = parseFloat(val); } } - if (typeabbr === "arr") { + if (typeabbr === 'arr') { try { - val = JSON.parse( "[" + val + "]" ); + val = JSON.parse('[' + val + ']'); } catch (error) { // boo return false; @@ -7337,7 +7589,7 @@ $(function(){ } if (val === undefined) { // Bang - val = "!"; + val = '!'; saveToState = false; } if (saveToState) { @@ -7348,7 +7600,9 @@ $(function(){ }, disconnect: function (event) { //HACK - var edge = this.model.parentGraph.get("edges").getByCid( $(event.target).parents(".edge-edit-item").attr("id") ); + var edge = this.model.parentGraph + .get('edges') + .getByCid($(event.target).parents('.edge-edit-item').attr('id')); if (edge) { this.model.parentGraph.removeEdge(edge); } @@ -7361,15 +7615,17 @@ $(function(){ _relatedEdges: null, relatedEdges: function () { // Resets to null on dis/connect - if ( this._relatedEdges === null ) { - this._relatedEdges = this.model.parentGraph.get("edges").filter( function (edge) { - return ( edge.Source === this.model || edge.Target === this.model ); - }, this); + if (this._relatedEdges === null) { + this._relatedEdges = this.model.parentGraph + .get('edges') + .filter(function (edge) { + return edge.Source === this.model || edge.Target === this.model; + }, this); // Toggle plugends if (this._relatedEdges.length >= 1) { - this.$(".plugend").show(); + this.$('.plugend').show(); } else { - this.$(".plugend").hide(); + this.$('.plugend').hide(); } // this.model.node.view.resetRelatedEdges(); } @@ -7390,68 +7646,64 @@ $(function(){ }, highlight: function () { // Called by edge view - var plugend = this.$(".plugend"); - plugend.addClass("highlight"); - setTimeout(function(){ - plugend.removeClass("highlight"); + var plugend = this.$('.plugend'); + plugend.addClass('highlight'); + setTimeout(function () { + plugend.removeClass('highlight'); }, 1000); }, publishPort: function () { // Make breakout var breakout = this.model.parentNode.parentGraph.addNode({ - src: "meemoo:subgraph/input", + src: 'meemoo:subgraph/input', x: 100, y: 100, w: 80, h: 60, state: { - label: this.model.id + label: this.model.id, }, - parentGraph: this.model.parentNode.parentGraph + parentGraph: this.model.parentNode.parentGraph, }); // Connect edge var edge = new Iframework.Edge({ - source: [breakout.id, "data"], + source: [breakout.id, 'data'], target: [this.model.parentNode.id, this.model.id], - parentGraph: this.model.parentNode.parentGraph + parentGraph: this.model.parentNode.parentGraph, }); - this.model.parentNode.parentGraph.addEdge( edge ); - } - + this.model.parentNode.parentGraph.addEdge(edge); + }, }); - }); -$(function(){ - +$(function () { Iframework.PortOut = Iframework.Port.extend({ defaults: { - name: "", - type: "", - description: "", - "default": null + name: '', + type: '', + description: '', + default: null, }, initializeView: function () { - this.view = new Iframework.PortOutView({model:this}); + this.view = new Iframework.PortOutView({model: this}); return this.view; - } + }, }); - + Iframework.PortsOut = Backbone.Collection.extend({ - model: Iframework.PortOut + model: Iframework.PortOut, }); - }); -$(function(){ - - var portOutTemplate = +$(function () { + // prettier-ignore + var portOutTemplate = '
'+ '<%= name %>'+ ''+ '
'+ ''; - + // var popupTemplate = // '
'+ // ''+ @@ -7466,83 +7718,89 @@ $(function(){ // '
'; Iframework.PortOutView = Iframework.PortView.extend({ - tagName: "div", - className: "port", + tagName: 'div', + className: 'port', portOutTemplate: _.template(portOutTemplate), // popupTemplate: _.template(popupTemplate), // edgeEditTemplate: _.template(edgeEditTemplate), events: { - "mousedown": "highlightEdge", - "click .hole": "clickhole", - "dragstart .hole": "dragstart", - "drag .hole, .holehelper": "drag", - "dragstop .hole, .holehelper": "dragstop", - "dragstart .plugend": "unplugstart", - "drag .plugend": "unplugdrag", - "dragstop .plugend": "unplugstop", - "drop": "drop", - "click .disconnect": "disconnect" + mousedown: 'highlightEdge', + 'click .hole': 'clickhole', + 'dragstart .hole': 'dragstart', + 'drag .hole, .holehelper': 'drag', + 'dragstop .hole, .holehelper': 'dragstop', + 'dragstart .plugend': 'unplugstart', + 'drag .plugend': 'unplugdrag', + 'dragstop .plugend': 'unplugstop', + drop: 'drop', + 'click .disconnect': 'disconnect', // "click .publish-port": "publishPort" }, render: function () { - this.$el.html( this.portOutTemplate(this.model.toJSON()) ); - this.$el.addClass("port-out"); - this.$(".hole") - .draggable({ - helper: function (e) { - return $(''); - } - }); - this.$(".plugend") - .draggable({ - helper: function (e) { - return $(''); - } - }); + this.$el.html(this.portOutTemplate(this.model.toJSON())); + this.$el.addClass('port-out'); + this.$('.hole').draggable({ + helper: function (e) { + return $(''); + }, + }); + this.$('.plugend').draggable({ + helper: function (e) { + return $(''); + }, + }); // Drag from hole - this.$(".hole") - .data({ - model: this.model - }); - + this.$('.hole').data({ + model: this.model, + }); + // The whole port is droppable - var accept = ""; - var type = this.model.get("type_class"); - if (type === "all"){ - accept = ".hole-in, .plugend-out"; + var accept = ''; + var type = this.model.get('type_class'); + if (type === 'all') { + accept = '.hole-in, .plugend-out'; } else { - accept = ".hole-in.hole-all, .hole-in.hole-"+type+", .plugend-out.plugend-all, .plugend-out.plugend-"+type; + accept = + '.hole-in.hole-all, .hole-in.hole-' + + type + + ', .plugend-out.plugend-all, .plugend-out.plugend-' + + type; // Anything can hit an in bang - accept += ", .hole-in.hole-bang, .plugend-out.plugend-string"; + accept += ', .hole-in.hole-bang, .plugend-out.plugend-string'; } - if (type === "int" || type === "float" || type === "number") { + if (type === 'int' || type === 'float' || type === 'number') { // Allow int and float -> string - accept += ", .hole-in.hole-string, .plugend-out.plugend-string"; + accept += ', .hole-in.hole-string, .plugend-out.plugend-string'; // Allow all int float number to connect - accept += ", .hole-in.hole-int, .hole-in.hole-float, .hole-out.hole-number, .plugend-out.plugend-int, .plugend-out.plugend-float, .plugend-out.plugend-number"; + accept += + ', .hole-in.hole-int, .hole-in.hole-float, .hole-out.hole-number, .plugend-out.plugend-int, .plugend-out.plugend-float, .plugend-out.plugend-number'; } this.$el.droppable({ - "hoverClass": "drophover", - "accept": accept + hoverClass: 'drophover', + accept: accept, }); - this.$(".plugend").hide(); + this.$('.plugend').hide(); // Disable selection for better drag+drop - this.$(".portshown").disableSelection(); - + this.$('.portshown').disableSelection(); }, dragstart: function (event, ui) { // Add a mask so that iframes don't steal mouse this.model.node.parentGraph.view.maskFrames(); - + // Highlight matching ins or outs - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole") - .addClass('fade'); - $("div.ports-"+(this.model.isIn ? "out" : "in")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + (this.model.isIn ? 'out' : 'in') + ' span.hole' + ).addClass('fade'); + $( + 'div.ports-' + + (this.model.isIn ? 'out' : 'in') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); Iframework.edgePreview = edgePreview; @@ -7558,13 +7816,13 @@ $(function(){ var dragY = ui.offset.top + 8 + Iframework.shownGraph.view.el.scrollTop; var thisX = this.portOffsetLeft(); var thisY = this.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? dragX-2 : thisX), - fromY: (this.model.isIn ? dragY : thisY), - toX: (this.model.isIn ? thisX : dragX+20), - toY: (this.model.isIn ? thisY : dragY) + fromX: this.model.isIn ? dragX - 2 : thisX, + fromY: this.model.isIn ? dragY : thisY, + toX: this.model.isIn ? thisX : dragX + 20, + toY: this.model.isIn ? thisY : dragY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -7576,12 +7834,12 @@ $(function(){ // Remove iframe masks this.model.node.parentGraph.view.unmaskFrames(); - $(".hole").removeClass("fade highlight"); - + $('.hole').removeClass('fade highlight'); + // Edge preview Iframework.edgePreview.remove(); Iframework.edgePreview = undefined; - if (this.relatedEdges().length < 1){ + if (this.relatedEdges().length < 1) { this.$('.plugend').hide(); } @@ -7595,19 +7853,19 @@ $(function(){ this.armDelete = false; } else { // Connect wire - var from = $(ui.draggable).data("model"); + var from = $(ui.draggable).data('model'); var to = this.model; - var source = (this.model.isIn ? from : to); - var target = (this.model.isIn ? to : from); + var source = this.model.isIn ? from : to; + var target = this.model.isIn ? to : from; var edge = new Iframework.Edge({ source: [source.node.id, source.id], target: [target.node.id, target.id], - parentGraph: this.model.parentNode.parentGraph + parentGraph: this.model.parentNode.parentGraph, }); if (Iframework.edgePreview) { edge._color = Iframework.edgePreview._color; } - if (edge.parentGraph.addEdge(edge)){ + if (edge.parentGraph.addEdge(edge)) { edge.connect(); } } @@ -7620,12 +7878,16 @@ $(function(){ topConnectedEdge: function () { var topConnected; var topZ = 0; - _.each(this.relatedEdges(), function(edge){ - if (edge.view && edge.view._z >= topZ) { - topZ = edge.view._z; - topConnected = edge; - } - }, this); + _.each( + this.relatedEdges(), + function (edge) { + if (edge.view && edge.view._z >= topZ) { + topZ = edge.view._z; + topConnected = edge; + } + }, + this + ); return topConnected; }, unplugstart: function (event, ui) { @@ -7634,21 +7896,29 @@ $(function(){ // Find top connected wire var lastConnected = this.topConnectedEdge(); - if (!lastConnected) { return false; } + if (!lastConnected) { + return false; + } this.unpluggingEdge = lastConnected; this.unpluggingEdge.view.dim(); - if (this.relatedEdges().length===1) { - this.$(".plugend").hide(); + if (this.relatedEdges().length === 1) { + this.$('.plugend').hide(); } - var thatPort = this.model.isIn ? this.unpluggingEdge.Source : this.unpluggingEdge.Target; - this.$(".plugend").data("model", thatPort); - + var thatPort = this.model.isIn + ? this.unpluggingEdge.Source + : this.unpluggingEdge.Target; + this.$('.plugend').data('model', thatPort); + // Highlight related ins or outs - $("div.ports-"+(this.model.isIn ? "in" : "out")+" span.hole-" + this.model.get('type_class')) - .addClass('highlight'); - + $( + 'div.ports-' + + (this.model.isIn ? 'in' : 'out') + + ' span.hole-' + + this.model.get('type_class') + ).addClass('highlight'); + // Edge preview var edgePreview = new Iframework.EdgeView(); edgePreview.setColor(this.unpluggingEdge.view._color); @@ -7663,16 +7933,18 @@ $(function(){ if (Iframework.edgePreview && this.unpluggingEdge) { var dragX = ui.offset.left + Iframework.shownGraph.view.el.scrollLeft; var dragY = ui.offset.top + 6 + Iframework.shownGraph.view.el.scrollTop; - var thatPortView = this.model.isIn ? this.unpluggingEdge.Source.view : this.unpluggingEdge.Target.view; + var thatPortView = this.model.isIn + ? this.unpluggingEdge.Source.view + : this.unpluggingEdge.Target.view; var thatX = thatPortView.portOffsetLeft(); var thatY = thatPortView.portOffsetTop(); - + // Edge preview var positions = { - fromX: (this.model.isIn ? thatX : dragX-2), - fromY: (this.model.isIn ? thatY : dragY), - toX: (this.model.isIn ? dragX+20 : thatX), - toY: (this.model.isIn ? dragY : thatY) + fromX: this.model.isIn ? thatX : dragX - 2, + fromY: this.model.isIn ? thatY : dragY, + toX: this.model.isIn ? dragX + 20 : thatX, + toY: this.model.isIn ? dragY : thatY, }; Iframework.edgePreview.setPositions(positions); Iframework.edgePreview.redraw(); @@ -7684,7 +7956,7 @@ $(function(){ if (this.armDelete && this.unpluggingEdge) { this.model.parentGraph.removeEdge(this.unpluggingEdge); } else { - this.$(".plugend").show(); + this.$('.plugend').show(); this.unpluggingEdge.view.undim(); } this.armDelete = false; @@ -7695,45 +7967,47 @@ $(function(){ clickhole: function (event) { // Hide previous connected edges editor $('div.edge-edit').remove(); - - var hole = this.$(".hole"); - + + var hole = this.$('.hole'); + // Show connected edges editor var isIn = this.model.isIn; - var portName = this.model.get("name"); - + var portName = this.model.get('name'); + var popupEl = this.popupTemplate(this.model.toJSON()); popupEl = $(popupEl); this.$el.append(popupEl); // Close button - popupEl.children("button.close") - .click(function(){ - $('div.edge-edit').remove(); - Iframework.selectedPort = null; - }); + popupEl.children('button.close').click(function () { + $('div.edge-edit').remove(); + Iframework.selectedPort = null; + }); - var typeabbr = this.model.get("type").substring(0,3); - - $("#select_"+this.model.id) - .button({ - icons: { - primary: "ui-icon-power" - } - }); + var typeabbr = this.model.get('type').substring(0, 3); + + $('#select_' + this.model.id).button({ + icons: { + primary: 'ui-icon-power', + }, + }); if (this.relatedEdges().length > 0) { popupEl.append('

disconnect

'); - _.each(this.relatedEdges(), function (edge) { - var edgeEditEl = this.edgeEditTemplate(edge.view); - popupEl.append(edgeEditEl); - }, this); + _.each( + this.relatedEdges(), + function (edge) { + var edgeEditEl = this.edgeEditTemplate(edge.view); + popupEl.append(edgeEditEl); + }, + this + ); } // This input's options - if (this.model.get("options") && this.model.get("options").length > 0) { + if (this.model.get('options') && this.model.get('options').length > 0) { this.$('input').autocomplete({ minLength: 0, - source: this.model.get("options") + source: this.model.get('options'), }); } @@ -7742,7 +8016,9 @@ $(function(){ }, disconnect: function (event) { //HACK - var edge = this.model.parentGraph.get("edges").getByCid( $(event.target).parents(".edge-edit-item").attr("id") ); + var edge = this.model.parentGraph + .get('edges') + .getByCid($(event.target).parents('.edge-edit-item').attr('id')); if (edge) { this.model.parentGraph.removeEdge(edge); } @@ -7755,15 +8031,17 @@ $(function(){ _relatedEdges: null, relatedEdges: function () { // Resets to null on dis/connect - if ( this._relatedEdges === null ) { - this._relatedEdges = this.model.parentGraph.get("edges").filter( function (edge) { - return ( edge.Source === this.model || edge.Target === this.model ); - }, this); + if (this._relatedEdges === null) { + this._relatedEdges = this.model.parentGraph + .get('edges') + .filter(function (edge) { + return edge.Source === this.model || edge.Target === this.model; + }, this); // Toggle plugends if (this._relatedEdges.length >= 1) { - this.$(".plugend").show(); + this.$('.plugend').show(); } else { - this.$(".plugend").hide(); + this.$('.plugend').hide(); } // this.model.node.view.resetRelatedEdges(); } @@ -7784,124 +8062,128 @@ $(function(){ }, highlight: function () { // Called by edge view - var plugend = this.$(".plugend"); - plugend.addClass("highlight"); - setTimeout(function(){ - plugend.removeClass("highlight"); + var plugend = this.$('.plugend'); + plugend.addClass('highlight'); + setTimeout(function () { + plugend.removeClass('highlight'); }, 1000); }, publishPort: function () { // Make breakout var breakout = this.model.parentNode.parentGraph.addNode({ - src: "meemoo:subgraph/output", + src: 'meemoo:subgraph/output', x: 500, y: 500, w: 80, h: 60, state: { - label: this.model.id + label: this.model.id, }, - parentGraph: this.model.parentNode.parentGraph + parentGraph: this.model.parentNode.parentGraph, }); // Connect edge var edge = new Iframework.Edge({ - source: [this.model.parentNode.id, this.model.id], - target: [breakout.id, "data"], - parentGraph: this.model.parentNode.parentGraph + source: [this.model.parentNode.id, this.model.id], + target: [breakout.id, 'data'], + parentGraph: this.model.parentNode.parentGraph, }); - this.model.parentNode.parentGraph.addEdge( edge ); - } - + this.model.parentNode.parentGraph.addEdge(edge); + }, }); - }); // Module is used for Iframework.Library and has info about ins and outs // Node is used by Graph, and has info about x, y, w, h -$(function(){ - +$(function () { Iframework.Module = Backbone.Model.extend({ defaults: { - "src": "", - "info": {} + src: '', + info: {}, }, initialize: function () { - var srcSplit = this.get("src").split(":"); - this.isNative = (srcSplit[0] === "meemoo"); + var srcSplit = this.get('src').split(':'); + this.isNative = srcSplit[0] === 'meemoo'; if (this.isNative) { - this.groupAndName = srcSplit[1].split("/"); + this.groupAndName = srcSplit[1].split('/'); } }, initializeView: function () { if (!this.view) { - this.view = new Iframework.ModuleView({model:this}); + this.view = new Iframework.ModuleView({model: this}); } return this.view; }, toJSON: function () { return { - "src": this.get("src"), - "info": this.get("info") + src: this.get('src'), + info: this.get('info'), }; - } + }, }); - + Iframework.Modules = Backbone.Collection.extend({ model: Iframework.Module, findOrAdd: function (node) { var module; - module = this.find(function(module){ - return module.get("src") === node.get("src"); + module = this.find(function (module) { + return module.get('src') === node.get('src'); }); if (!module) { - module = new Iframework.Module({"node":node}); + module = new Iframework.Module({node: node}); this.add(module); } return module; - } + }, }); - }); -$(function(){ - - var template = +$(function () { + var template = '
' + '

<%= info.title %>

'; Iframework.ModuleView = Backbone.View.extend({ - tagName: "div", - className: "library-module", + tagName: 'div', + className: 'library-module', template: _.template(template), events: { - "click .addnode": "addNode", - "dragstart .addnode": "dragStart", - "dragstop .addnode": "dragStop" + 'click .addnode': 'addNode', + 'dragstart .addnode': 'dragStart', + 'dragstop .addnode': 'dragStop', }, initialize: function () { this.render(); var self = this; - this.$(".addnode") + this.$('.addnode') .data({module: this.model}) .draggable({ helper: function () { - var h = $('
') - .data({ - "meemoo-drag-type": "library-module" - }); - // .text( self.model.get("info")["title"]); + var h = $('
').data({ + 'meemoo-drag-type': 'library-module', + }); + // .text( self.model.get("info")["title"]); if (self.model.isNative) { - h.addClass("module-icon-"+self.model.groupAndName[0]+"-"+self.model.groupAndName[1]); + h.addClass( + 'module-icon-' + + self.model.groupAndName[0] + + '-' + + self.model.groupAndName[1] + ); } - $(".app").append(h); + $('.app').append(h); return h; - } + }, }); - + if (this.model.isNative) { - this.$(".addnode").addClass("module-icon-"+this.model.groupAndName[0]+"-"+this.model.groupAndName[1]); + this.$('.addnode').addClass( + 'module-icon-' + + this.model.groupAndName[0] + + '-' + + this.model.groupAndName[1] + ); } return this; @@ -7909,38 +8191,35 @@ $(function(){ render: function () { this.$el.html(this.template(this.model.toJSON())); }, - addNode: function(options) { - Iframework.$(".addbyurlinput").val( this.model.get("src") ); + addNode: function (options) { + Iframework.$('.addbyurlinput').val(this.model.get('src')); Iframework.addByUrl(options); }, - dragAddNode: function(options) { + dragAddNode: function (options) { // options has x and y from GraphView.drop() - options.src = this.model.get("src"); - Iframework.shownGraph.addNode( options ); + options.src = this.model.get('src'); + Iframework.shownGraph.addNode(options); }, - dragStart: function() { + dragStart: function () { Iframework.shownGraph.view.maskFrames(); }, - dragStop: function() { + dragStop: function () { Iframework.shownGraph.view.unmaskFrames(); - } - + }, }); - }); -$(function(){ - +$(function () { Iframework.Edge = Backbone.Model.extend({ defaults: { - source: [0, "default"], - target: [0, "default"] + source: [0, 'default'], + target: [0, 'default'], }, initialize: function () { - this.parentGraph = this.get("parentGraph"); + this.parentGraph = this.get('parentGraph'); }, initializeView: function () { - this.view = new Iframework.EdgeView({model:this}); + this.view = new Iframework.EdgeView({model: this}); return this.view; }, Source: null, @@ -7950,14 +8229,25 @@ $(function(){ connect: function () { // Called from graph.connectEdges() try { - this.Source = this.parentGraph.get("nodes").get( this.get("source")[0] ).Outputs.get( this.get("source")[1] ); - this.Target = this.parentGraph.get("nodes").get( this.get("target")[0] ).Inputs.get( this.get("target")[1] ); + this.Source = this.parentGraph + .get('nodes') + .get(this.get('source')[0]) + .Outputs.get(this.get('source')[1]); + this.Target = this.parentGraph + .get('nodes') + .get(this.get('target')[0]) + .Inputs.get(this.get('target')[1]); } catch (e) { - console.warn("Edge source or target port not found, try #"+this.connectTryCount+": "+this.toString()); + console.warn( + 'Edge source or target port not found, try #' + + this.connectTryCount + + ': ' + + this.toString() + ); if (this.connectTryCount > 0) { this.connectTryCount--; var self = this; - _.delay(function(){ + _.delay(function () { self.connect(); }, 1000); } @@ -7969,10 +8259,10 @@ $(function(){ this.Source.connect(this); this.Target.connect(this); this.Source.node.receive({ - connect: { + connect: { source: [this.Source.node.id, this.Source.id], - target: [this.Target.node.id, this.Target.id] - } + target: [this.Target.node.id, this.Target.id], + }, }); if (this.parentGraph.view) { this.parentGraph.view.addEdge(this); @@ -7983,12 +8273,12 @@ $(function(){ this.connected = true; // Set up listener - this.Source.node.on( "send:"+this.Source.id, this.send, this ); + this.Source.node.on('send:' + this.Source.id, this.send, this); return this; }, send: function (value) { - this.Target.node.receive( this.Target.id, value ); + this.Target.node.receive(this.Target.id, value); }, disconnect: function () { // Called from graph.removeEdge() @@ -7996,10 +8286,10 @@ $(function(){ this.Source.disconnect(this); this.Target.disconnect(this); this.Source.node.receive({ - disconnect: { + disconnect: { source: [this.Source.node.id, this.Source.id], - target: [this.Target.node.id, this.Target.id] - } + target: [this.Target.node.id, this.Target.id], + }, }); if (this.Target.node.view && this.Target.node.view.Native) { this.Target.node.view.Native.disconnectEdge(this); @@ -8010,35 +8300,41 @@ $(function(){ } // Remove listener - this.Source.node.off( "send:"+this.Source.id, this.send, this ); + this.Source.node.off('send:' + this.Source.id, this.send, this); this.connected = false; }, - remove: function(){ + remove: function () { this.parentGraph.removeEdge(this); }, toJSON: function () { return { - source: this.get("source"), - target: this.get("target") + source: this.get('source'), + target: this.get('target'), }; }, - toString: function(){ - return this.get("source")[0]+":"+this.get("source")[1]+"->"+this.get("target")[0]+":"+this.get("target")[1]; - } + toString: function () { + return ( + this.get('source')[0] + + ':' + + this.get('source')[1] + + '->' + + this.get('target')[0] + + ':' + + this.get('target')[1] + ); + }, }); - + Iframework.Edges = Backbone.Collection.extend({ - model: Iframework.Edge + model: Iframework.Edge, }); - }); -$(function(){ - +$(function () { Iframework.EdgeView = Backbone.View.extend({ - tagName: "div", - className: "edge", + tagName: 'div', + className: 'edge', // template: _.template(template), positions: null, graphSVGElement: null, @@ -8069,18 +8365,26 @@ $(function(){ $(this.elementWire) .data({ - "model": this.model + model: this.model, }) - .click( function(event){ - $(event.target).data("model").view.click(event); + .click(function (event) { + $(event.target).data('model').view.click(event); }); // Listen for changes to redraw if (this.model.Source) { - this.model.Source.parentNode.on("change:x change:y change:w change:h", this.redraw, this); + this.model.Source.parentNode.on( + 'change:x change:y change:w change:h', + this.redraw, + this + ); } if (this.model.Target) { - this.model.Target.parentNode.on("change:x change:y", this.redraw, this); + this.model.Target.parentNode.on( + 'change:x change:y', + this.redraw, + this + ); } } }, @@ -8088,18 +8392,18 @@ $(function(){ this.calcPositions(); this.elementGroup = this.makeSVG('g', { - "transform": "translate("+this.svgX()+","+this.svgY()+")", - "class": "wire-group"+(this.isPreview ? " preview" : "") + transform: 'translate(' + this.svgX() + ',' + this.svgY() + ')', + class: 'wire-group' + (this.isPreview ? ' preview' : ''), }); this.elementShadow = this.makeSVG('path', { - "class": "wire-shadow", - "d": this.svgPathShadow() + class: 'wire-shadow', + d: this.svgPathShadow(), }); this.elementWire = this.makeSVG('path', { - "class": "wire", - "d": this.svgPath(), - "stroke": this.color() + class: 'wire', + d: this.svgPath(), + stroke: this.color(), }); this.elementGroup.appendChild(this.elementShadow); @@ -8109,8 +8413,8 @@ $(function(){ // Unhide port plugends if (this.model) { - this.model.Source.view.$(".plugend").show(); - this.model.Target.view.$(".plugend").show(); + this.model.Source.view.$('.plugend').show(); + this.model.Target.view.$('.plugend').show(); this.model.parentGraph.view.resizeEdgeSVG(); } @@ -8118,9 +8422,12 @@ $(function(){ }, redraw: function () { this.calcPositions(); - $(this.elementGroup).attr( "transform", "translate("+this.svgX()+", "+this.svgY()+")" ); - $(this.elementWire).attr( "d", this.svgPath() ); - $(this.elementShadow).attr( "d", this.svgPathShadow() ); + $(this.elementGroup).attr( + 'transform', + 'translate(' + this.svgX() + ', ' + this.svgY() + ')' + ); + $(this.elementWire).attr('d', this.svgPath()); + $(this.elementShadow).attr('d', this.svgPathShadow()); if (this.model) { this.model.parentGraph.view.resizeEdgeSVG(); @@ -8137,12 +8444,24 @@ $(function(){ calcPositions: function () { if (this.model) { // Connected edge - var sourceName = this.model.get("source")[1]; - var targetName = this.model.get("target")[1]; - this.positions.fromX = this.model.Source.view.portOffsetLeft('out', sourceName); - this.positions.fromY = this.model.Source.view.portOffsetTop('out', sourceName); - this.positions.toX = this.model.Target.view.portOffsetLeft('in', targetName); - this.positions.toY = this.model.Target.view.portOffsetTop('in', targetName); + var sourceName = this.model.get('source')[1]; + var targetName = this.model.get('target')[1]; + this.positions.fromX = this.model.Source.view.portOffsetLeft( + 'out', + sourceName + ); + this.positions.fromY = this.model.Source.view.portOffsetTop( + 'out', + sourceName + ); + this.positions.toX = this.model.Target.view.portOffsetLeft( + 'in', + targetName + ); + this.positions.toY = this.model.Target.view.portOffsetTop( + 'in', + targetName + ); } }, svgX: function () { @@ -8164,10 +8483,32 @@ $(function(){ var fromY = this.positions.fromY - this.svgY(); var toX = this.positions.toX - this.svgX(); var toY = this.positions.toY - this.svgY(); - return "M "+ fromX +" "+ fromY + - " L "+ (fromX+this.pathStraight) +" "+ fromY + - " C "+ (fromX+this.pathCurve) +" "+ fromY +" "+ (toX-this.pathCurve) +" "+ toY +" "+ (toX-this.pathStraight) +" "+ toY + - " L "+ toX +" "+ toY; + return ( + 'M ' + + fromX + + ' ' + + fromY + + ' L ' + + (fromX + this.pathStraight) + + ' ' + + fromY + + ' C ' + + (fromX + this.pathCurve) + + ' ' + + fromY + + ' ' + + (toX - this.pathCurve) + + ' ' + + toY + + ' ' + + (toX - this.pathStraight) + + ' ' + + toY + + ' L ' + + toX + + ' ' + + toY + ); }, svgPathShadow: function () { // Same as svgPath() but y+1 @@ -8175,10 +8516,32 @@ $(function(){ var fromY = this.positions.fromY - this.svgY() + 1; var toX = this.positions.toX - this.svgX(); var toY = this.positions.toY - this.svgY() + 1; - return "M "+ fromX +" "+ fromY + - " L "+ (fromX+this.pathStraight) +" "+ fromY + - " C "+ (fromX+this.pathCurve) +" "+ fromY +" "+ (toX-this.pathCurve) +" "+ toY +" "+ (toX-this.pathStraight) +" "+ toY + - " L "+ toX +" "+ toY; + return ( + 'M ' + + fromX + + ' ' + + fromY + + ' L ' + + (fromX + this.pathStraight) + + ' ' + + fromY + + ' C ' + + (fromX + this.pathCurve) + + ' ' + + fromY + + ' ' + + (toX - this.pathCurve) + + ' ' + + toY + + ' ' + + (toX - this.pathStraight) + + ' ' + + toY + + ' L ' + + toX + + ' ' + + toY + ); }, color: function () { if (this._color) { @@ -8193,49 +8556,57 @@ $(function(){ return Iframework.wireColors[Iframework.wireColorIndex]; } }, - setColor: function(c) { + setColor: function (c) { this._color = c; - $(this.elementWire).attr( "stroke", c ); + $(this.elementWire).attr('stroke', c); }, label: function () { - return this.model.get("source")[0] +":"+ this.model.get("source")[1] + - '' + - this.model.get("target")[0] +":"+ this.model.get("target")[1]; + return ( + this.model.get('source')[0] + + ':' + + this.model.get('source')[1] + + '' + + this.model.get('target')[0] + + ':' + + this.model.get('target')[1] + ); }, // Thanks bobince http://stackoverflow.com/a/3642265/592125 - makeSVG: function(tag, attrs) { - var el= document.createElementNS('http://www.w3.org/2000/svg', tag); + makeSVG: function (tag, attrs) { + var el = document.createElementNS('http://www.w3.org/2000/svg', tag); for (var k in attrs) { - if (k === "xlink:href") { + if (k === 'xlink:href') { // Pssh namespaces... - el.setAttributeNS('http://www.w3.org/1999/xlink','href', attrs[k]); + el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', attrs[k]); } else { el.setAttribute(k, attrs[k]); } } return el; }, - dim: function(){ - $(this.elementGroup).attr("opacity", 0.2); + dim: function () { + $(this.elementGroup).attr('opacity', 0.2); }, - undim: function(){ - $(this.elementGroup).attr("opacity", 1); + undim: function () { + $(this.elementGroup).attr('opacity', 1); }, - click: function(event) { + click: function (event) { // If not on top already - if (this._z < this.model.parentGraph.edgeCount-1) { + if (this._z < this.model.parentGraph.edgeCount - 1) { // Bring to top (z-order of SVG can't be done with CSS) this.graphSVGElement.appendChild(this.elementGroup); this._z = this.model.parentGraph.edgeCount++; } this.highlight(); }, - highlight: function() { + highlight: function () { // Highlight edge and plugends var shadow = $(this.elementShadow); - shadow.attr("class", "wire-shadow highlight"); - setTimeout(function(){ - shadow.attr("class", "wire-shadow"); + shadow.attr('class', 'wire-shadow highlight'); + setTimeout(function () { + shadow.attr('class', 'wire-shadow'); }, 1000); if (this.model.Source.view) { this.model.Source.view.highlight(); @@ -8243,49 +8614,43 @@ $(function(){ if (this.model.Target.view) { this.model.Target.view.highlight(); } - } - - + }, }); - }); -$(function(){ - +$(function () { // Router var IframeworkRouter = Backbone.Router.extend({ routes: { - "example/:url": "loadExample", // #example/url - "new": "newBlank", - "local/:url": "loadLocal", - "gist/https://gist.github.com/:user/:id": "loadGistUgly", // Redirects - "gist/:id": "loadGist", - "*path": "default" - }, - loadExample: function(url) { + 'example/:url': 'loadExample', // #example/url + new: 'newBlank', + 'local/:url': 'loadLocal', + 'gist/https://gist.github.com/:user/:id': 'loadGistUgly', // Redirects + 'gist/:id': 'loadGist', + '*path': 'default', + }, + loadExample: function (url) { Iframework.loadExample(url); }, loadGistUgly: function (id) { - this.navigate("gist/"+id, {replace: true}); + this.navigate('gist/' + id, {replace: true}); this.loadGist(id); }, - loadLocal: function(url) { + loadLocal: function (url) { Iframework.loadLocal(url); }, - loadGist: function(id) { + loadGist: function (id) { Iframework.loadFromGistId(id); }, - newBlank: function() { + newBlank: function () { Iframework.newBlank(); }, - 'default': function() { - - } + default: function () {}, }); Iframework.router = new IframeworkRouter(); Backbone.history.start(); - }); + // extends src/node-box-native-view.js $(function () { @@ -8540,8 +8905,8 @@ $(function () { }); }); -$( function() { - +$(function () { + // prettier-ignore var template = $( '
'+ '
'+ @@ -8555,36 +8920,36 @@ $( function() { '
' ); - var code = template.find("textarea"); + var code = template.find('textarea'); // Add menu - Iframework.addMenu("source", template, "icon-cog"); + Iframework.addMenu('source', template, 'icon-cog'); // On change update code view - Iframework.on("change", function(graph){ - if (Iframework.graph && Iframework.$(".menu-source").is(":visible")) { + Iframework.on('change', function (graph) { + if (Iframework.graph && Iframework.$('.menu-source').is(':visible')) { // Bookmark to scroll back to - var scrollBackTop = code.prop("scrollTop"); - code.val( JSON.stringify(Iframework.graph.toJSON(), null, " ") ); - code.scrollTop( scrollBackTop ); + var scrollBackTop = code.prop('scrollTop'); + code.val(JSON.stringify(Iframework.graph.toJSON(), null, ' ')); + code.scrollTop(scrollBackTop); } }); - var sourceRefresh = function(){ - code.val( JSON.stringify(Iframework.graph, null, " ") ); + var sourceRefresh = function () { + code.val(JSON.stringify(Iframework.graph, null, ' ')); }; - template.find(".sourcerefresh").click(sourceRefresh); + template.find('.sourcerefresh').click(sourceRefresh); // On show manu update source - Iframework.on("showmenu:source", sourceRefresh); + Iframework.on('showmenu:source', sourceRefresh); - var sourceCompress = function(){ - code.val( JSON.stringify(Iframework.graph, null, "") ); + var sourceCompress = function () { + code.val(JSON.stringify(Iframework.graph, null, '')); }; - template.find(".sourcecompress").click(sourceCompress); + template.find('.sourcecompress').click(sourceCompress); // Apply source to test graph - var sourceApply = function(){ + var sourceApply = function () { // try { // var newGraph = JSON.parse( this.$(".sourceedit textarea").val() ); // this.loadGraph(newGraph); @@ -8596,8 +8961,8 @@ $( function() { // } var graph; try { - graph = JSON.parse( code.val() ); - } catch(error){ + graph = JSON.parse(code.val()); + } catch (error) { return false; } if (graph) { @@ -8605,16 +8970,15 @@ $( function() { // reset localStorage version Iframework._loadedLocalApp = null; sourceRefresh(); - g.trigger("change"); + g.trigger('change'); } return false; }; - template.find(".sourceapply").click(sourceApply); - -} ); - -$( function () { + template.find('.sourceapply').click(sourceApply); +}); +$(function () { + // prettier-ignore var template = $( '
'+ '
'+ @@ -8629,25 +8993,26 @@ $( function () { ); // Add menu - Iframework.addMenu("library", template, "icon-plus"); + Iframework.addMenu('library', template, 'icon-plus'); Iframework.loadLibrary = function (library) { - var autocompleteData = []; - var accordion = $("
"); + var accordion = $('
'); for (var category in library) { - if (!library.hasOwnProperty(category)){continue;} + if (!library.hasOwnProperty(category)) { + continue; + } var section = $('
'); // section title - section.append( $('

'+category+"

") ); + section.append($('

' + category + '

')); // section items - var sectionDiv = $("
"); + var sectionDiv = $('
'); var modules = library[category]; - for (var i = 0; i" ) - .append( '' + item.title + "
" + item.description + "
" ) - .appendTo( ul ); - }; + .data('ui-autocomplete')._renderItem = function (ul, item) { + // Custom display + return $('
  • ') + .append( + '' + + item.title + + '
    ' + + item.description + + '
    ' + ) + .appendTo(ul); + }; }; - var addByUrl = Iframework.addByUrl = function() { - var addByUrlInput = Iframework.$(".addbyurlinput"); + var addByUrl = (Iframework.addByUrl = function () { + var addByUrlInput = Iframework.$('.addbyurlinput'); addByUrlInput.blur(); var url = addByUrlInput.val(); - if (url !== "") { - var graphEl = Iframework.$(".graph"); + if (url !== '') { + var graphEl = Iframework.$('.graph'); Iframework.shownGraph.addNode({ - "src": url, - "x": Math.floor(graphEl.scrollLeft() + graphEl.width()/2) - 100, - "y": Math.floor(graphEl.scrollTop() + graphEl.height()/2) - 100 + src: url, + x: Math.floor(graphEl.scrollLeft() + graphEl.width() / 2) - 100, + y: Math.floor(graphEl.scrollTop() + graphEl.height() / 2) - 100, }); - addByUrlInput - .val("") - .attr("placeholder", "loading..."); - window.setTimeout(function(){ - addByUrlInput - .attr("placeholder", "search or url"); + addByUrlInput.val('').attr('placeholder', 'loading...'); + window.setTimeout(function () { + addByUrlInput.attr('placeholder', 'search or url'); }, 1000); } return false; - }; + }); // Form submit action - template.find(".addbyurl").submit(function(){ + template.find('.addbyurl').submit(function () { addByUrl(); return false; }); - // var library = $('
      '); // var addNode = function(node, x, y) { @@ -8786,18 +9159,17 @@ $( function () { // Iframework.addPlugin("library", library); // Iframework.plugins.library.update = update; +}); -} ); - -$( function() { - - var IMGUR_ID = "9877b5345adf3fc"; +$(function () { + var IMGUR_ID = '9877b5345adf3fc'; // Shim - if ( !window.URL ) { + if (!window.URL) { window.URL = window.webkitURL || window.msURL || window.oURL || false; } + // prettier-ignore var template = $( '
      '+ '
      '+ @@ -8817,109 +9189,115 @@ $( function() { ); // Add menu - Iframework.addMenu("images", template, "icon-picture"); + Iframework.addMenu('images', template, 'icon-picture'); // Set info - var info = template.find(".info"); + var info = template.find('.info'); var setInfo = function (string) { info.text(string); }; // Open image panel by dragging over show button - Iframework.$(".show-images").droppable({ - accept: ".canvas, .image", - tolerance: "pointer", - activeClass: "drop-indicator", + Iframework.$('.show-images').droppable({ + accept: '.canvas, .image', + tolerance: 'pointer', + activeClass: 'drop-indicator', over: function (event, ui) { - $(this).trigger("click"); - } + $(this).trigger('click'); + }, }); // Drop panels - template.find(".image-drop").droppable({ - accept: ".canvas", - tolerance: "pointer", - hoverClass: "drop-hover", - activeClass: "drop-active", + template.find('.image-drop').droppable({ + accept: '.canvas', + tolerance: 'pointer', + hoverClass: 'drop-hover', + activeClass: 'drop-active', // Don't also drop on graph - greedy: true + greedy: true, }); - template.find(".public-drop").droppable({ + template.find('.public-drop').droppable({ // also accept img drops - accept: ".canvas, .image" + accept: '.canvas, .image', }); - template.find(".local-drop").on("drop", function(event, ui) { - var image = ui.helper.data("meemoo-drag-canvas"); - if (!image) { return false; } + template.find('.local-drop').on('drop', function (event, ui) { + var image = ui.helper.data('meemoo-drag-canvas'); + if (!image) { + return false; + } var thumbnail = makeThumbnail(image); - localListing.append( thumbnail ); + localListing.append(thumbnail); }); // Make thumbnail element - var makeThumbnail = function(image){ + var makeThumbnail = function (image) { // image can be Image or Canvas var el = $('
      ') .append(image) .draggable({ - cursor: "pointer", - cursorAt: { top: -10, left: -10 }, - helper: function( event ) { - var helper = $( '

      Copy this

      ' ) - .data({ - "meemoo-drag-type": "canvas", - "meemoo-source-image": image - }); + cursor: 'pointer', + cursorAt: {top: -10, left: -10}, + helper: function (event) { + var helper = $( + '

      Copy this

      ' + ).data({ + 'meemoo-drag-type': 'canvas', + 'meemoo-source-image': image, + }); $(document.body).append(helper); - _.delay(function(){ + _.delay(function () { dragCopyCanvas(helper); }, 100); return helper; - } + }, }); return el; }; var dragCopyCanvas = function (helper) { - if (!helper) { return; } - var image = helper.data("meemoo-source-image"); - var canvasCopy = document.createElement("canvas"); + if (!helper) { + return; + } + var image = helper.data('meemoo-source-image'); + var canvasCopy = document.createElement('canvas'); canvasCopy.width = image.naturalWidth ? image.naturalWidth : image.width; - canvasCopy.height = image.naturalHeight ? image.naturalHeight : image.height; - canvasCopy.getContext("2d").drawImage(image, 0, 0); - helper.data("meemoo-drag-canvas", canvasCopy); + canvasCopy.height = image.naturalHeight + ? image.naturalHeight + : image.height; + canvasCopy.getContext('2d').drawImage(image, 0, 0); + helper.data('meemoo-drag-canvas', canvasCopy); helper.append(canvasCopy); }; - // Local files - var fileInput = template.find(".file-input-local"); - var localListing = template.find(".local-listing"); - fileInput.change( function (event) { + var fileInput = template.find('.file-input-local'); + var localListing = template.find('.local-listing'); + fileInput.change(function (event) { // Load local image var files = event.target.files; - for (var i=0; i'+ ''+ @@ -9077,57 +9462,58 @@ $( function() { '
      '; Iframework.plugins.images.GalleryImageView = Backbone.View.extend({ - tagName: "div", - className: "meemoo-plugin-images-thumbnail", + tagName: 'div', + className: 'meemoo-plugin-images-thumbnail', template: _.template(imageTemplate), events: { - "click .delete": "destroyModel" + 'click .delete': 'destroyModel', }, initialize: function () { this.$el.html(this.template(this.model.toJSON())); var mainsrc = this.model.get('link'); - this.$(".link").attr("href", mainsrc); + this.$('.link').attr('href', mainsrc); var animated = this.model.get('animated'); if (animated) { var animatedLink = this.model.get('gifv') || mainsrc; - this.$(".link-animated") - .attr("href", animatedLink) - .css({"display": "inline-block"}); + this.$('.link-animated') + .attr('href', animatedLink) + .css({display: 'inline-block'}); } // Load thumbnail - var img = this.$("img")[0]; + var img = this.$('img')[0]; img.src = this.model.get('linkThumb'); this.$el.draggable({ - cursor: "pointer", - cursorAt: { top: -10, left: -10 }, - helper: function( event ) { - var helper = $( '

      Copy this

      ' ) - .data({ - "meemoo-drag-type": "canvas", - "meemoo-source-image": img, - "meemoo-image-url": mainsrc - }); + cursor: 'pointer', + cursorAt: {top: -10, left: -10}, + helper: function (event) { + var helper = $( + '

      Copy this

      ' + ).data({ + 'meemoo-drag-type': 'canvas', + 'meemoo-source-image': img, + 'meemoo-image-url': mainsrc, + }); $(document.body).append(helper); - _.delay(function(){ + _.delay(function () { dragCopyCanvas(helper); }, 100); return helper; - } + }, }); - var publicListing = template.find(".public-listing"); - publicListing.prepend( this.el ); + var publicListing = template.find('.public-listing'); + publicListing.prepend(this.el); this.model.on('destroy', this.remove, this); return this; }, destroyModel: function () { - if (!window.confirm("Are you sure you want to delete this image?")) { + if (!window.confirm('Are you sure you want to delete this image?')) { return; } // Delete imgur file @@ -9139,9 +9525,9 @@ $( function() { url: 'https://api.imgur.com/3/image/' + deletehash, type: 'delete', headers: { - Authorization: 'Client-ID ' + IMGUR_ID + Authorization: 'Client-ID ' + IMGUR_ID, }, - success: function(response) { + success: function (response) { if (response.success) { model.destroy(); setInfo('Deleted'); @@ -9151,7 +9537,7 @@ $( function() { }, error: function () { setInfo('Delete failed'); - } + }, }); return; } @@ -9160,52 +9546,50 @@ $( function() { }, remove: function () { this.$el.remove(); - } - + }, }); // Load local images from local storage var publicImages = new Iframework.plugins.images.GalleryImages(); publicImages.fetch({ - success: function(e) { - publicImages.each(function(image){ + success: function (e) { + publicImages.each(function (image) { image.initializeView(); }); }, error: function (e) { - console.warn("error loading public images"); - } + console.warn('error loading public images'); + }, }); +}); -} ); -$(function(){ - +$(function () { // Start Iframework.allLoaded(); // Bind shortcuts - Mousetrap.bind(['command+a', 'ctrl+a'], function(e) { + Mousetrap.bind(['command+a', 'ctrl+a'], function (e) { if (Iframework.shownGraph && Iframework.shownGraph.view) { e.preventDefault(); Iframework.shownGraph.view.selectAll(); } }); - Mousetrap.bind(['command+x', 'ctrl+x'], function(e) { + Mousetrap.bind(['command+x', 'ctrl+x'], function (e) { if (Iframework.shownGraph && Iframework.shownGraph.view) { // e.preventDefault(); Iframework.shownGraph.view.cut(); } }); - Mousetrap.bind(['command+c', 'ctrl+c'], function(e) { + Mousetrap.bind(['command+c', 'ctrl+c'], function (e) { if (Iframework.shownGraph && Iframework.shownGraph.view) { // e.preventDefault(); Iframework.shownGraph.view.copy(); } }); - Mousetrap.bind(['command+v', 'ctrl+v'], function(e) { + Mousetrap.bind(['command+v', 'ctrl+v'], function (e) { if (Iframework.shownGraph && Iframework.shownGraph.view) { // e.preventDefault(); Iframework.shownGraph.view.paste(); @@ -9218,5 +9602,4 @@ $(function(){ // Iframework.shownGraph.view.deleteSelected(); // } // }); - -}); \ No newline at end of file +}); diff --git a/build/meemoo-iframework.min.js b/build/meemoo-iframework.min.js index 432c36f..bec94c9 100644 --- a/build/meemoo-iframework.min.js +++ b/build/meemoo-iframework.min.js @@ -1,4 +1,4 @@ -/*! Meemoo Iframework http://meemoo.org/ - v0.3.5 - 2024-12-23 (8:49:13 PM GMT+0200) +/*! Meemoo Iframework http://meemoo.org/ - v0.3.5 - 2024-12-26 (5:34:19 PM GMT+0200) * Copyright (c) 2024 Forrest Oliphant; Licensed MIT, AGPL. */ -!function(){var e=this,t=e._,s={},o=Array.prototype,i=Object.prototype,n=Function.prototype,r=o.push,a=o.slice,l=o.concat,d=i.toString,h=i.hasOwnProperty,u=o.forEach,c=o.map,p=o.reduce,f=o.reduceRight,g=o.filter,m=o.every,v=o.some,w=o.indexOf,b=o.lastIndexOf,y=Array.isArray,i=Object.keys,k=n.bind,x=function(e){return e instanceof x?e:this instanceof x?void(this._wrapped=e):new x(e)};"undefined"!=typeof exports?(exports="undefined"!=typeof module&&module.exports?module.exports=x:exports)._=x:e._=x,x.VERSION="1.4.4";var I=x.each=x.forEach=function(e,t,i){if(null!=e)if(u&&e.forEach===u)e.forEach(t,i);else if(e.length===+e.length){for(var n=0,o=e.length;n=r.computed&&(r={value:e,computed:i})}),r.value},x.min=function(e,n,o){if(!n&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!n&&x.isEmpty(e))return 1/0;var r={computed:1/0,value:1/0};return I(e,function(e,t,i){i=n?n.call(o,e,t,i):e;r.computed>i&&(r={value:e,computed:i})}),r.value},x.shuffle=function(e){var t,i=0,n=[];return I(e,function(e){t=x.random(i++),n[i-1]=n[t],n[t]=e}),n};function S(t){return x.isFunction(t)?t:function(e){return e[t]}}x.sortBy=function(e,t,n){var o=S(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:o.call(n,e,t,i)}}).sort(function(e,t){var i=e.criteria,n=t.criteria;if(i!==n){if(n>>1;o>i.call(n,e[a])?r=1+a:s=a}return r},x.toArray=function(e){return e?x.isArray(e)?a.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return null==e?0:(e.length===+e.length?e:x.keys(e)).length},x.first=x.head=x.take=function(e,t,i){return null==e?void 0:null==t||i?e[0]:a.call(e,0,t)},x.initial=function(e,t,i){return a.call(e,0,e.length-(null==t||i?1:t))},x.last=function(e,t,i){return null==e?void 0:null==t||i?e[e.length-1]:a.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,i){return a.call(e,null==t||i?1:t)},x.compact=function(e){return x.filter(e,x.identity)};function C(e,t,i){return I(e,function(e){x.isArray(e)?t?r.apply(i,e):C(e,t,i):i.push(e)}),i}x.flatten=function(e,t){return C(e,t,[])},x.without=function(e){return x.difference(e,a.call(arguments,1))},x.uniq=x.unique=function(i,n,e,t){x.isFunction(n)&&(t=e,e=n,n=!1);var t=e?x.map(i,e,t):i,o=[],r=[];return I(t,function(e,t){(n?t&&r[r.length-1]===e:x.contains(r,e))||(r.push(e),o.push(i[t]))}),o},x.union=function(){return x.uniq(l.apply(o,arguments))},x.intersection=function(e){var i=a.call(arguments,1);return x.filter(x.uniq(e),function(t){return x.every(i,function(e){return 0<=x.indexOf(e,t)})})},x.difference=function(e){var t=l.apply(o,a.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){for(var e=a.call(arguments),t=x.max(x.pluck(e,"length")),i=Array(t),n=0;n":">",'"':""","'":"'","/":"/"}};P.unescape=x.invert(P.escape);var G={escape:RegExp("["+x.keys(P.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(P.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(t){x[t]=function(e){return null==e?"":(""+e).replace(G[t],function(e){return P[t][e]})}}),x.result=function(e,t){if(null==e)return null;t=e[t];return x.isFunction(t)?t.call(e):t},x.mixin=function(i){I(x.functions(i),function(e){var t=x[e]=i[e];x.prototype[e]=function(){var e=[this._wrapped];return r.apply(e,arguments),L.call(this,t.apply(x,e))}})};var T=0;x.uniqueId=function(e){var t=++T+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var O=/(.)^/,A={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(r,e,t){var i;t=x.defaults({},t,x.templateSettings);var n=RegExp([(t.escape||O).source,(t.interpolate||O).source,(t.evaluate||O).source].join("|")+"|$","g"),s=0,a="__p+='";r.replace(n,function(e,t,i,n,o){return a+=r.slice(s,o).replace(M,function(e){return"\\"+A[e]}),t&&(a+="'+\n((__t=("+t+"))==null?'':_.escape(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),n&&(a+="';\n"+n+"\n__p+='"),s=o+e.length,e}),a+="';\n",a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+(a=!t.variable?"with(obj||{}){\n"+a+"}\n":a)+"return __p;\n";try{i=Function(t.variable||"obj","_",a)}catch(e){throw e.source=a,e}if(e)return i(e,x);e=function(e){return i.call(this,e,x)};return e.source="function("+(t.variable||"obj")+"){\n"+a+"}",e},x.chain=function(e){return x(e).chain()};var L=function(e){return this._chain?x(e).chain():e};x.mixin(x),I(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var i=o[t];x.prototype[t]=function(){var e=this._wrapped;return i.apply(e,arguments),"shift"!=t&&"splice"!=t||0!==e.length||delete e[0],L.call(this,e)}}),I(["concat","join","slice"],function(e){var t=o[e];x.prototype[e]=function(){return L.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(){var e=this,t=e.Backbone,i=[],p=i.push,o=i.slice,f=i.splice,s="undefined"!=typeof exports?exports:e.Backbone={};s.VERSION="1.0.0";var g=e._;g||"undefined"==typeof require||(g=require("underscore")),s.$=e.jQuery||e.Zepto||e.ender||e.$,s.noConflict=function(){return e.Backbone=t,this},s.emulateHTTP=!1,s.emulateJSON=!1;var r=s.Events={on:function(e,t,i){return u(this,"on",e,[t,i])&&t&&(this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t,context:i,ctx:i||this})),this},once:function(e,t,i){if(!u(this,"once",e,[t,i])||!t)return this;var n=this,o=g.once(function(){n.off(e,o),t.apply(this,arguments)});return o._callback=t,this.on(e,o,i)},off:function(e,t,i){var n,o,r,s,a,l,h,d;if(!this._events||!u(this,"off",e,[t,i]))return this;if(!e&&!t&&!i)return this._events={},this;for(a=0,l=(s=e?[e]:g.keys(this._events)).length;a").attr(e),this.setElement(e,!1))}}),s.sync=function(e,t,i){var n=y[e];g.defaults(i=i||{},{emulateHTTP:s.emulateHTTP,emulateJSON:s.emulateJSON});var o,r={type:n,dataType:"json"};i.url||(r.url=g.result(t,"url")||P()),null!=i.data||!t||"create"!==e&&"update"!==e&&"patch"!==e||(r.contentType="application/json",r.data=JSON.stringify(i.attrs||t.toJSON(i))),i.emulateJSON&&(r.contentType="application/x-www-form-urlencoded",r.data=r.data?{model:r.data}:{}),!i.emulateHTTP||"PUT"!==n&&"DELETE"!==n&&"PATCH"!==n||(r.type="POST",i.emulateJSON&&(r.data._method=n),o=i.beforeSend,i.beforeSend=function(e){if(e.setRequestHeader("X-HTTP-Method-Override",n),o)return o.apply(this,arguments)}),"GET"===r.type||i.emulateJSON||(r.processData=!1),"PATCH"!==r.type||!window.ActiveXObject||window.external&&window.external.msActiveXFilteringEnabled||(r.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});r=i.xhr=s.ajax(g.extend(r,i));return t.trigger("request",t,r,i),r};var y={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"};s.ajax=function(){return s.$.ajax.apply(s.$,arguments)};var i=s.Router=function(e){(e=e||{}).routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},k=/\((.*?)\)/g,x=/(\(\?)?:\w+/g,I=/\*\w+/g,_=/[\-{}\[\]+?.,\\\^$|#\s]/g;g.extend(i.prototype,r,{initialize:function(){},route:function(t,i,n){g.isRegExp(t)||(t=this._routeToRegExp(t)),g.isFunction(i)&&(n=i,i=""),n=n||this[i];var o=this;return s.history.route(t,function(e){e=o._extractParameters(t,e);n&&n.apply(o,e),o.trigger.apply(o,["route:"+i].concat(e)),o.trigger("route",i,e),s.history.trigger("route",o,i,e)}),this},navigate:function(e,t){return s.history.navigate(e,t),this},_bindRoutes:function(){if(this.routes){this.routes=g.result(this,"routes");for(var e,t=g.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(_,"\\$&").replace(k,"(?:$1)?").replace(x,function(e,t){return t?e:"([^/]+)"}).replace(I,"(.*?)"),new RegExp("^"+e+"$")},_extractParameters:function(e,t){t=e.exec(t).slice(1);return g.map(t,function(e){return e?decodeURIComponent(e):null})}});var $=s.History=function(){this.handlers=[],g.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},S=/^[#\/]|\s+$/g,E=/^\/+|\/+$/g,C=/msie [\w.]+/,N=/\/$/;$.started=!1,g.extend($.prototype,r,{interval:50,getHash:function(e){e=(e||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(e,t){return null==e&&(this._hasPushState||!this._wantsHashChange||t?(e=this.location.pathname,t=this.root.replace(N,""),e.indexOf(t)||(e=e.substr(t.length))):e=this.getHash()),e.replace(S,"")},start:function(e){if($.started)throw new Error("Backbone.history has already been started");$.started=!0,this.options=g.extend({},{root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var t=this.getFragment(),e=document.documentMode,e=C.exec(navigator.userAgent.toLowerCase())&&(!e||e<=7);this.root=("/"+this.root+"/").replace(E,"/"),e&&this._wantsHashChange&&(this.iframe=s.$('